当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - Unable to update Now Playing tile on music playback in Windows Phone 7

问题描述:

I'm trying to build a music player app in Windows Phone 7. Adding items to history page of the Music+Videos app is working fine. But, when trying to associate the "Now Playing" tile so that it opens my app when it is clicked (or via volume music controls), it throws an exception.

Working code (only history):

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

}

The exception generated is:

An unhandled exception of type 'System.InvalidOperationException' occurred in Microsoft.Phone.dll

Additional information: partial read?

Please help.

Thanks,

Siddhant

分享给朋友:
您可能感兴趣的文章:
随机阅读: