2

我正在尝试在 Windows Phone 7 中构建音乐播放器应用程序。将项目添加到 Music+Videos 应用程序的历史记录页面工作正常。但是,当尝试关联“正在播放”磁贴以便在单击它时(或通过音量音乐控件)打开我的应用程序时,它会引发异常。

工作代码(仅历史):

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”类型的未处理异常

附加信息:部分阅读?

请帮忙。

谢谢, 悉达特

4

0 回答 0