AudioStreamer
AudioStreamer copied to clipboard
background Problem with playing more than one music URL
Hello, i'am trying to use the AudioStreamer in my project and i'am having some troubles with playing more than one music in background. Like this:
I start one music..so when it is finished starts another music...and it`s ok! But if i start one music and press the home button my app goes to background and the first musics keeps playing but when it tries go to the next song it stops...and only begins when i go back to the application.
I read something about AudioSession and i think thats why the fist music keeps playing...but i
m doing something to play the second music (which is other url) that i dont know if is right... when the player gets idle state - (void)playbackStateChanged: --> ([streamer isIdle]) I kill the player and inits another one...it works with the application opened but in background no...
Thanks.
That's normal. Your app will be able to run in the background only if there is audio playing. When the audio stops (ie: going to the next track), it will only resume when the player will go foreground again. To workaround this, you should control a separate background task ([[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:]) when the audio stops so you can do your stuff in between.
i tried doing this.. but it say something like this when try to play next song
Audio queue start failed. err: ÕG -12985
Okay it fixed when i commented out AudioSessionSetActive(false);
#ifdef TARGET_OS_IPHONE //AudioSessionSetActive(false); #endif
Ref: http://stackoverflow.com/q/3121841/140220