2015-02-06 87 views
0

我使用的Windows Phone 8.1運行時 我得到我的歌在獨立存儲錯誤時播放文件.MP3(StorageFile)與BackgroundMediaPlayer獨立存儲的Windows Phone 8.1 RT

我的代碼: storageFile是在獨立存儲

IRandomAccessStream stream = await storagefile.OpenAsync(FileAccessMode.Read); 
BackgroundMediaPlayer.Current.SetStreamSource(stream); 
BackgroundMediaPlayer.Current.Play(); 

當我打它,但它不能正常工作,如照片(嘗試仿真器和設備管腔520)

http://photoshare7.com/image/f5a

_message: 無法轉換類型 'Windows.Media.Playback.MediaPlayer' 的對象鍵入 'Windows.Media.Playback.IMediaPlayerSource'

請幫我.Tks all.Sr我的英語水平。

回答

1

我剛剛遇到同樣的問題:)這發生在您從前臺應用程序調用SetStreamSource。見[https://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn642090.aspx]。要從文件播放音頻,您需要向背景音頻播放器發送消息(請參閱[How to pass an object to background project in Windows Phone?])。

+0

Tks For share 我使用StorageFile(My Song in device)中的Pass Path從ForeGround到Mess(Wp8.1 RT)的背景,並且工作正常。 – MrTy 2015-03-01 19:08:40

相關問題