Sometimes Play icon on status bar disappear while using AVQueueplayer

184 views Asked by At

I want to show the play icon on status bar in iOS while app is playing audio. I use AVQueuePlayer to play audio items. All works well but problem I am facing is play icon doesn't show on status bar sometimes.

The app has to support play/pause. When user taps on pause, I pause the queue player and tapping on play button will start playing the queue again. When user taps on play again, I do seeking of the player item so that it will be in sync with what it is supposed to be played at that time. But some times after tapping on play again, the queue seeks to proper time and plays but play icon doesn't show up in the status bar.

I tried by commenting out the seek code and just did play/pause. The play icon shows/hides correctly, but I am not sure what is happening with seekTime API. If I use this to seek, sometimes the icon doesn't show time.

Is this something issue happening in seekTime: API? I am using the following code for seek [self.player.currentItem seekToTime:seekTime];

Please help me on this issue.

Thanks

1

There are 1 answers

1
Patricio Diego On

I don't use AVQueuePlayer but I had a similar problem. I'm using AVAudioPlayer only and when the application starts I play an audio which is then repeated constantly. For some reason, at different times, the play icon disappears but the audio is still playing.

My solution was to apply the response of "One Man Crew" in How to display playing indication icon on status bar?

But, in addition, every time I play again, I use the following:

[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];

I don't know if it is correct, I am new in ios development, but currently is working to me.

Please let me know if there is a better solution.

Diego.