Windows Phone 7 中的媒体播放器
我正在使用 Windows Phone 7 中的媒体播放器来播放手机歌曲集中的音乐。但是当它播放音乐时,它们将是一个例外,并且错误指出
FrameworkDispatcher.Update 尚未被调用。定期调用 FrameworkDispatcher.Update 是“即发即忘”音效和框架事件正常运行所必需的。
我应该如何修改我的代码?
private void songBtn_Click(object sender, RoutedEventArgs e)
{
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);
}
MediaPlayer.Play(ml.Songs[0]);
}
}
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
FrameworkDispatcher.Update has not been called. Regular FrameworkDispatcher.Update calls are necessary for fire and forget sound effects and framework events to function correctly.
How should i go about modifying my code?
private void songBtn_Click(object sender, RoutedEventArgs e)
{
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);
}
MediaPlayer.Play(ml.Songs[0]);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
必须拨打
每当您拨打 XNA 媒体库时都
所以你的代码应该是这样的
You have to call
whenever you make a call to an XNA media library
so your code should look like this
发生该错误的原因是您在常规 Windows Phone 7 应用程序中使用 XNA Framework。
如果您阅读错误描述,您将获得 MSDN 链接:在 Windows Phone 中启用 XNA Framework 事件应用程序,它准确地解释了要做什么。
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.