AudioStreamer icon indicating copy to clipboard operation
AudioStreamer copied to clipboard

background Problem with playing more than one music URL

Open thiagoananias opened this issue 14 years ago • 3 comments

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 im 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.

thiagoananias avatar Feb 18 '11 17:02 thiagoananias

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.

bkill avatar Apr 06 '11 07:04 bkill

i tried doing this.. but it say something like this when try to play next song Audio queue start failed. err: ÕG -12985

yasirmturk avatar Feb 01 '12 07:02 yasirmturk

Okay it fixed when i commented out AudioSessionSetActive(false);

#ifdef TARGET_OS_IPHONE //AudioSessionSetActive(false); #endif

Ref: http://stackoverflow.com/q/3121841/140220

yasirmturk avatar Feb 01 '12 12:02 yasirmturk