我正在尝试在Windows Phone 7中构建音乐播放器应用程序。将项目添加到音乐+视频应用程序的历史记录页面工作正常。但是,当尝试关联“正在播放”磁贴以便在单击它时(或通过音量控件)打开我的应用时,它会抛出异常。
工作代码(仅限历史记录):
if (currentsong != null)
{
MediaHistoryItem historyItem = new MediaHistoryItem();
historyItem.Title = currentsong.Name;
historyItem.Source = "";
historyItem.ImageStream = currentsong.Album.GetAlbumArt();
if (historyItem.ImageStream == null)
{
StreamResourceInfo sri = Application.GetResourceStream(new Uri("noalbum2.png", UriKind.Relative));
historyItem.ImageStream = sri.Stream;
}
MediaHistory mediaHistory = MediaHistory.Instance;
mediaHistory.WriteRecentPlay(historyItem); //WORKS
mediaHistory.NowPlaying = historyItem; //Throws exception
}
生成的异常是:
Microsoft.Phone.dll中出现未处理的“System.InvalidOperationException”类型异常
其他信息:部分阅读?
请帮忙。
谢谢, Siddhant