Mobile browsers prevent video autoplay for understandable reasons. I have a video background on a site, so control buttons are out of question, but I thought that I could pop up window with some info and a button, where the user can accept the background video (triggering manual play) or not, and change it to some static pic.
So the question is: is there a way to tell if the autoplay was interrupted by the browser?
I tried onerror
but it doesn't fire so I tried to onsuspend
as well:
HTML:
<video id='bgvid' src='bgvid.mp4' type='video/mp4' autoplay loop onsuspend='video_suspended()'>
Javascript:
function video_suspended() {
$bgvideoElement=$("#bgvid").get(0);
//Check if reason for suspend was completion or browser interruption
if($bgvideoElement.readyState<1) {
//Here comes some pop-up window and a button to
$bgvideoElement.play();
}
}
It works pretty well on tablet (Chrome), but on desktop (Chrome) onsuspend
keeps triggering infinitely (Firefox is alright though).
Any ideas on Chrome problem or any alternatives?