问题
I use Windows Phone 8.1 Runtime I get my song in isolated storage
My code : storageFile is song in isolated storage
IRandomAccessStream stream = await storagefile.OpenAsync(FileAccessMode.Read);
BackgroundMediaPlayer.Current.SetStreamSource(stream);
BackgroundMediaPlayer.Current.Play();
When I play it,but it not work , like photo (try emulator and device lumina 520)
http://photoshare7.com/image/f5a
_message: Unable to cast object of type 'Windows.Media.Playback.MediaPlayer ' to type 'Windows.Media.Playback.IMediaPlayerSource'
Please Help me .Tks all.Sr my English.
回答1:
I just ran into the same issue :) This happens when you call SetStreamSource
from foreground application. See [https://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn642090.aspx]. To play audio from a file, you need to send background audio player a message (see [How to pass an object to background project in Windows Phone?).
来源:https://stackoverflow.com/questions/28360812/error-when-play-file-mp3-storagefile-with-backgroundmediaplayer-in-isolated