Ejemplo n.º 1
0
 public void StopMusic()
 {
     if (MusicState == AudioPlayState.Playing)
     {
         MusicStreamer.Stop();
         MusicStreamer.Dispose();
         MusicDecoder.Dispose();
         MusicStreamer = null;
         if (Stream != null)
         {
             try {
                 Stream.Dispose();
                 // Analysis disable once EmptyGeneralCatchClause
             } catch { }
         }
     }
 }
Ejemplo n.º 2
0
 public void PlayMusic(string filename)
 {
     StopMusic();
     Stream        = File.OpenRead(filename);
     MusicDecoder  = DecoderFactory.GetDecoderFromStream(Stream);
     MusicStreamer = new StreamingAudio(Device, MusicDecoder.Format, MusicDecoder.SampleRate);
     MusicStreamer.BufferNeeded     += (instance, buffer) => MusicDecoder.Read(buffer.Length, buffer);
     MusicStreamer.PlaybackFinished += (sender, e) => {
         if (loopMusic)
         {
             PlayMusic(filename);
         }
         else
         {
             MusicStreamer.Dispose();
             MusicDecoder.Dispose();
             MusicStreamer = null;
         }
     };
     MusicStreamer.Play();
 }
Ejemplo n.º 3
0
 public void StopMusic()
 {
     if (MusicState == AudioPlayState.Playing) {
         MusicStreamer.Stop ();
         MusicStreamer.Dispose ();
         MusicDecoder.Dispose ();
         MusicStreamer = null;
         if (Stream != null) {
             try {
                 Stream.Dispose ();
             // Analysis disable once EmptyGeneralCatchClause
             } catch { }
         }
     }
 }
Ejemplo n.º 4
0
 public void PlayMusic(string filename)
 {
     StopMusic ();
     Stream = File.OpenRead (filename);
     MusicDecoder = DecoderFactory.GetDecoderFromStream (Stream);
     MusicStreamer = new StreamingAudio (Device, MusicDecoder.Format, MusicDecoder.SampleRate);
     MusicStreamer.BufferNeeded += (instance, buffer) => MusicDecoder.Read (buffer.Length, buffer);
     MusicStreamer.PlaybackFinished += (sender, e) => {
         if (loopMusic)
             PlayMusic (filename);
         else {
             MusicStreamer.Dispose ();
             MusicDecoder.Dispose ();
             MusicStreamer = null;
         }
     };
     MusicStreamer.Play ();
 }
Ejemplo n.º 5
0
 internal void Remove(StreamingAudio audio)
 {
     toRemove.Enqueue (audio);
 }
Ejemplo n.º 6
0
 internal void Add(StreamingAudio audio)
 {
     toAdd.Enqueue (audio);
 }
Ejemplo n.º 7
0
 internal void Remove(StreamingAudio audio)
 {
     toRemove.Enqueue(audio);
 }
Ejemplo n.º 8
0
 internal void Add(StreamingAudio audio)
 {
     toAdd.Enqueue(audio);
 }