The Player class implements a simple player for playback of an MPEG audio stream.
Example #1
0
        /// <summary> Decompresses audio data from an InputStream and plays it
        /// back through an AudioDevice. The playback is run on a newly
        /// created thread. 
        /// 
        /// </summary>
        /// <param name="in	The">InputStream that provides the MPEG audio data.
        /// </param>
        /// <param name="dev	The">AudioDevice to use to sound the decompressed data. 
        /// 
        /// @throws JavaLayerException if there was a problem decoding
        /// or playing the audio data.
        /// 
        /// </param>
        protected internal virtual void play(System.IO.Stream @in, AudioDevice dev)
        {
            stopPlayer();

            if (@in != null && dev != null)
            {
                player = new Player(@in, dev);
                playerThread = createPlayerThread();
                playerThread.Start();
            }
        }
Example #2
0
 /// <summary> Stops the audio player. If the player is already stopped
 /// this method is a no-op.  
 /// </summary>
 protected internal virtual void stopPlayer()
 {
     if (player != null)
     {
         player.close();
         player = null;
         playerThread = null;
     }
 }
Example #3
0
 public virtual void play()
 {
     try
     {
         System.Console.Out.WriteLine("playing " + fFilename + "...");
         System.IO.Stream in_Renamed = null;
         if (remote == true)
             in_Renamed = URLInputStream;
         else
             in_Renamed = InputStream;
         AudioDevice dev = AudioDevice;
         Player player = new Player(in_Renamed, dev);
         player.play();
     }
     catch (System.IO.IOException ex)
     {
         throw new JavaLayerException("Problem playing file " + fFilename, ex);
     }
     catch (System.Exception ex)
     {
         throw new JavaLayerException("Problem playing file " + fFilename, ex);
     }
 }