HTML5 Audio strange behavior with iOS lock screen - ios

I have a website that uses html5 audio blocks to play audio. When I drag the progress bar to jump to another part of the track, the timer stops incrementing and the play/pause button stops working. Does anybody know what properties on an HTML5 audio block the iOS lock screen is reading to show the progress bar?

Related

UIWebView Keep Video Playing After Exiting Fullscreen

In our app, we want to be able to keep a video playing after the user has quit fullscreen mode. The video is a YouTube one, thus it uses YTPlayerView framework, which uses UIWebView and iframe player to play the video.
As you have probably noticed, in iOS 11, when a web video enters fullscreen, there is only one 'X' button at the upper left corner to quit fullscreen and pause the video, instead of two(one 'Done' at the top and one arrow at the bottom) like before.
I have been able to get a UIWindowDidBecomeHidden notification when the fullscreen quits, and play the video programmatically, but then I realize that if the user has already paused the video manually before quitting fullscreen, it will start playing nonetheless when he/she quits. However, adding something in the YTPlayerDelegate won't do much since the system will pause the video(sending the stateDidChange delegate) before sending the notification, so I cannot differentiate between a manual pause when fullscreen and a system pause when quitting fullscreen.
My question is, is there a way to detect leaving fullscreen action before the system pauses the video? If not, is there a native API to have the player keep playing? If not either, is this feature possible? How would I achieve it? Thanks.

Sometimes Play icon on status bar disappear while using AVQueueplayer

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

Playing audio in the background when using a UIWebView

So I´ve don all the preliminary steps of setting the audioSession sharedInstance category, and activated playing audio in the background in the info.plist file
However I am using an UIWebView to display YouTube, and even thought background playing is
supported, pressing the home button the audio stops. Is this cause YouTube uses some built in player? cause when I play an video my tab bar controller disappears.
Is there a way of having it continue playing the youtube videos in background?

iOS6 Background Audio Overlap

I have an iOS app made with Pphonegap 1.8.1 and Sencha Touch 2 that plays HTML5 audio. I've set UIBackgroundModes -> audio in my info.plist and followed this answer to allow background audio on iOS6.
My issue is that whenever I play audio in the background, it will persist and overlap with previously played tracks. To reproduce:
Play HTML5 audio inside an app on an iOS 6 device.
Toggle the display off and on, so that you are on the lock screen (audio continues to play as expected).
Unlock and return to the app.
Stop the HTML5 audio and play another track.
Toggle the display off and on, so that you are on the lock screen (audio continues to play as expected).
Double tap the home button to display the audio controls on the lock screen, and tap the pause button.
Result:
The currently playing audio is paused but the previous audio (from step 1) now starts to play. If you tap the next track button, then the previous track, and then tap play, it will play both audio items at the same time.
Note:
On iOS 5.1, previously played background audio is not persisted.
Is there a way I can ensure only the last played audio from the app is available in the background on iOS 6?

iOS: background play from the browser?

Some iOS apps like Pandora continue playing audio after the app screen has been exited, and even after the device has been locked.
Is it possible to keep audio playing in this way from a browser tab? In other words, can I code an HTML5 page that plays audio and continues playing even after the iPhone is locked?
Yes, audio playing in a mobile Safari tab will continuously play even when multi-tasking or locking your screen. However, if you save the bookmark to the home screen, open, play audio, and then hop out to multi-task, the audio fades out.
Not possible... the browser displaying your page controls what happens when it is deactivated (sent to the background). HTML5 won't touch the behavior of the underlying browser as it relates to system events, so the only way to control background activity in iOS is to write a native app.

Resources