I’m building a site which will serve video as a background (using Joe Workmans Eclipse) above a certain screen size and serve a background slide show (also Eclipse) on smaller (e.g. mobile). The decision is done using Joe’s Agent stack.
However I think that this will be over ridden by a users browser settings on whether to autoplay videos or not. Is there a way to identify when video autoplay is off and hence serve the background slide show instead of showing the default (static) Video poster ?
Technically there appears to be a solution to detect if autoplay is supported. Part of the “Modernizr JS” library (Modernizr tests which native CSS3 and HTML5 features are available).
Now I don’t know if it helps you much but you would include this javascript
You would use the following .on() syntax for your test for autplay on and off:
Modernizr.on('videoautoplay', function(result){
if(result) {
// Do what you want if autoplay here
} else {
// Do what you want if NOT autoplay here
}
});
No, it actually does return the proper autoplay has been disabled by the user. I have autoplay disabled on most of my browsers. I have tested this function and if takes the false route for Safari and Chrome, even though the browser Support autoplay.
I then ran the same test with Microsoft Edge( I did not turn off autoplay on that one and it shows autoplay OK.