Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
341 views
in Technique[技术] by (71.8m points)

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...