Can you play a List<Song> continuously in the background on Windows Phone 8

夙愿已清 提交于 2019-12-12 04:09:47

问题


I have a list of songs (List<Song>) and i want to play all the songs even if the application goes into the background or under the lock screen.

I cannot use a SongCollection and MediaPlayer.Play(SongCollection) because i cannot create a SongCollection object from a List<Song>.

Is there anyway i can play this list of songs in the background, one by one (MediaPlayer.Play()) or otherwise?


回答1:


The answer is right in the documentation for SongCollection class: http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.media.songcollection.aspx

All of the collections, playlists, and queues returned by methods and properties in the Microsoft.Xna.Framework.Media namespace are immutable. You cannot add or remove objects from those collections or playlists. To create a custom 'playlist' of songs, games must maintain their own list of songs to play, and play those songs one at a time by calling MediaPlayer.Play.

The only thing you might be able to do is add a background audio agent to your app. More details on that here: http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202978(v=vs.105).aspx



来源:https://stackoverflow.com/questions/20363269/can-you-play-a-listsong-continuously-in-the-background-on-windows-phone-8

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