WP7 MediaPlayer判断播放完一个Song后接着播放另一个

  DispatcherTimer timer2 = new DispatcherTimer();
           timer2.Interval = TimeSpan.FromMilliseconds(33);
           timer2.Tick += delegate { try { FrameworkDispatcher.Update(); } catch { } };
           timer2.Start();



private void playSound()

       {
          // SongCollection mySongCollection;
           Song sound = Song.FromUri("music", new Uri("/sound/welcome.mp3", UriKind.RelativeOrAbsolute));
           MediaPlayer.Play(sound);
           MediaPlayer.MediaStateChanged += new EventHandler<EventArgs>(MediaPlayer_MediaStateChanged);
           
       }
       void MediaPlayer_MediaStateChanged(object sender, EventArgs e)
       {
           if ( MediaPlayer.State == MediaState.Paused)   //而不是 MediaState.Stop
           {
               Song sound = Song.FromUri("music", new Uri("/sound/olderHomepage2.mp3", UriKind.RelativeOrAbsolute));
              MediaPlayer.Play(sound);
           }

       }


或者

Song sound = Song.FromUri("music", new Uri("/sound/welcome.mp3", UriKind.RelativeOrAbsolute));
            FrameworkDispatcher.Update();
            MediaPlayer.Play(sound);

你可能感兴趣的:(WP7 MediaPlayer判断播放完一个Song后接着播放另一个)