Media player in Windows Phone 7

后端 未结 2 1163
陌清茗
陌清茗 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]);
    }
    
    0 讨论(0)
  • 2021-01-20 17:29

    The error is occouring because you're using the XNA Framework in a regular Windows Phone 7 application.

    If you read the error description, you would gotten this link to MSDN: Enable XNA Framework Events in Windows Phone Applications , which explains precisely what to do.

    0 讨论(0)
提交回复
热议问题