问题描述:

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

相关阅读:
Top