Media player in Windows Phone 7

后端 未结 2 1236
陌清茗
陌清茗 2021-01-20 17:11

I am using the media player in Windows Phone 7 to play the music in the phone song collection. But when it play the music they will be an exception and the error is stating

2条回答
  •  日久生厌
    2021-01-20 17:22

    You have to call

    FrameworkDispatcher.Update()
    

    whenever you make a call to an XNA media library so your code should look like this

    using (var ml = new MediaLibrary())
    {
    
      foreach (var song in ml.Songs)
      {
          System.Diagnostics.Debug.WriteLine(song.Artist + " " + song.Name);
          MessageBox.Show(song.Artist + " " + song.Name);
    
      }
      FrameworkDispatcher.Update();
      MediaPlayer.Play(ml.Songs[0]);
    }
    

提交回复
热议问题