Skip to content

Instantly share code, notes, and snippets.

@cameronjonesweb
Created November 30, 2018 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cameronjonesweb/0bffe4f2bad4c962956784d273c25338 to your computer and use it in GitHub Desktop.
Save cameronjonesweb/0bffe4f2bad4c962956784d273c25338 to your computer and use it in GitHub Desktop.
Fixes Vide.js videos not autoplaying on Safari
/**
* @link https://github.com/vodkabears/Vide/issues/206
*/
function cameronjoneswebAutoPlayVideo( video ) {
if ( video.readyState === 4 ) {
video.play();
} else {
setTimeout( cameronjoneswebAutoPlayVideo, 100, video );
}
}
jQuery( document ).ready( function () {
video = jQuery( '#my-video-selector' ).data( 'vide' ).getVideoObject();
cameronjoneswebAutoPlayVideo( video );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment