예제 #1
0
 /// <summary>
 /// Called when a new track requires audio decoding
 /// (typically because it is about to start playing)
 /// </summary>
 /// <param name="track">
 /// The track that needs audio streaming
 /// </param>
 /// <param name="streamer">
 /// The AudioStreamer object to which a MediaStreamSource should be
 /// attached to commence playback
 /// </param>
 /// <remarks>
 /// To invoke this method for a track set the Source parameter of the AudioTrack to null
 /// before setting  into the Track property of the BackgroundAudioPlayer instance
 /// property set to true;
 /// otherwise it is assumed that the system will perform all streaming
 /// and decoding
 /// </remarks>
 protected override void OnBeginStreaming(AudioTrack track, AudioStreamer streamer)
 {
     lock (AudioTrackStreamer.syncRoot)
     {
         AudioTrackStreamer.mss = new ShoutcastMediaStreamSource(new Uri(track.Tag));
         AudioTrackStreamer.mss.MetadataChanged += new RoutedEventHandler(AudioTrackStreamer.MetadataChanged);
         AudioTrackStreamer.mss.Closed          += (s, e) =>
         {
             this.NotifyComplete();
         };
         streamer.SetSource(AudioTrackStreamer.mss);
     }
 }
예제 #2
0
 /// <summary>
 /// Completely shuts down the AudioTrackStreamer.
 /// </summary>
 public static void ShutdownMediaStreamSource()
 {
     if (AudioTrackStreamer.mss != null)
     {
         lock (AudioTrackStreamer.syncRoot)
         {
             if (AudioTrackStreamer.mss != null)
             {
                 // Because of the NotifyComplete(), we need to set this BEFORE the MSS ends.
                 ShoutcastMediaStreamSource temp = AudioTrackStreamer.mss;
                 AudioTrackStreamer.mss = null;
                 temp.MetadataChanged  -= new System.Windows.RoutedEventHandler(AudioTrackStreamer.MetadataChanged);
                 temp.Dispose();
             }
         }
     }
 }