Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating new AVPlayer while in background does not work?

I'm playing music with an AVPlayer. Now at a certain time a NSTimer fires and I'dlike to fade over to another track. So I start fading out my AVPlayer and create a new AVPlayer instance to play the next song.

When on foreground this works as expected. But when my app is on background. The playing track fades out but the new AVPlayer instance does not start playing. Is it just not possible to create a new AVPlayer instance on background? or how can I make it play? Or is there another way to overlap two tracks?

I could do the playback with AVQeueuPalyer, but then I can't let tracks overlap. Any suggestions?

-- EDIT --

If it was not clear, I am able to play background audio as long as I want. Just creating a new AVPlayer instance in background does not work.

like image 991
V1ru8 Avatar asked Oct 09 '22 11:10

V1ru8


1 Answers

The correct way to do what I wanted seems to be AVMutableComposition. With that I don't need multiple AVPlayers and a few other benefits. For more details: I summarized it in a blogpost: http://www.postblog.me/2012/03/playing-multiple-overlapping-audio-tracks-in-background/

like image 148
V1ru8 Avatar answered Oct 13 '22 12:10

V1ru8