Search code examples
windows-phone-8audio-playerbackground-music

Windows phone 8: how to play background next song?


I'm programming an app which is able to play music in background. I'm using mediaplayer and Song(class xnalib), well since is not possible put file into mediaplayer.queue I can't figure out how can play next song in the "playlist". I'll try to make this scenario more clear with an example:

  • I play music with mediaplayer: MediaPlayer.Play(MysongArray[CurrentIndex]);
  • well now user put my app in background.

  • but when MysongArray[CurrentIndex] song is ended how play next song if my application is in background?

thanks


Solution

  • That's probably because you are playing a Song not a SongCollection - once it's ended it stops playing. Source: MSDN1, MSDN2. I belive (thounght I've not tried it) that you should create SongCollection (if it's possible) or Manage existing one. But this can be a hard job as @ToniPetrina answered here.

    As for me I would consider using Background Audio Player and How to play.
    Maybe this will help if you decide to use BAP - example how to use playlist.