0

I use avqueueplayer to play some very short audios. Once an item is completed, it shall pause for 2 second and then play the next item.

The problem is if the player is paused and at the same time, I press home button, it will not play the next item unless I re-enter the app.

The background play works fine if I press home button, and the player is not in paused status. How Should I sovle this problem? Thank you.

user2053760
  • 1,673
  • 2
  • 14
  • 19

1 Answers1

1

The audio will not be interrupted if it is continuous. But you need to declare your app's RemoteControlEvents for audio to be played in the background if it is, as you explained, paused or stopped.

[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
Aleksander Azizi
  • 9,829
  • 9
  • 59
  • 87
  • I did this.What I mean is once an item is comleted,I invoke [Player pause] to give a delay, and the perform selector [player play] delayed for 2 second, So if [Player pause] is called, and at the same time I enter background mode, the play will not continue playing. – user2053760 Mar 15 '16 at 06:37
  • In that case you should add secondary callback for starting to play music if the app enters background. `[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillResignActive:) name:UIApplicationWillResignActiveNotification object:nil];` `[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillTerminate:) name:UIApplicationWillTerminateNotification object:nil];` – Aleksander Azizi Mar 15 '16 at 06:43
  • 1
    Yes, I call player play when app will resign active and it works. Thank you. How brilliant you are. – user2053760 Mar 15 '16 at 07:12