Is there a work-around for Android Gingerbread, to detect when a user has exited the viewing of an HTML5 video in-browser? Basically Android phones launch HTML5 video into fullscreen (same as iPhone) webkitendfullscreen
or webkitfullscreenchange
doesn't fire on Android. So unable to detect exit of fullscreen before video playback ends.
One of the comments of this post says it's not supported in Android 2.3: How can I catch event ExitFullScreen of a video?
Anyone find a solve or work-around to this?
You don't get much to work with in the way of events for HTML5 video on Android 2.x...however, on Android 2.x the video will always play fullscreen, and therefore pause automatically on close. Unfortunately you don't get a pause
event like other browsers, but you do have access to two things:
1) The timeupdate
event, which gives you data several times a second as the video plays.
2) The currentTime
property of your video element.
So, while this is a bit of an ugly workaround, you could poll the currentTime
property regularly after the video starts to play, and if it is the same for more than like 500ms, consider the video to have paused (and therefore left fullscreen mode). You could also infer that the video is paused by the absence of a timeupdate
event in a given period of time. This has the potential of causing your page to redraw just from a user pausing the video...but knowing that you can find a way of doing it safely.
I realize this is an old question, but I hope this helps someone!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With