Error when Play file .mp3 (StorageFile ) with BackgroundMediaPlayer in isolated storage windows phone 8.1 rt

人走茶凉 提交于 2020-01-07 07:49:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!