Skip to content

Instantly share code, notes, and snippets.

@macedd
Created February 4, 2015 23:15
Show Gist options
  • Save macedd/e62e7e5153e833e78601 to your computer and use it in GitHub Desktop.
Save macedd/e62e7e5153e833e78601 to your computer and use it in GitHub Desktop.
WP Video (mediaelementjs) force autoload
$(window).on('load', function() {
var player = $('video.wp-video-shortcode').data('mediaelementplayer');
player.options.success = function(media, dom) {
if (media.pluginType === 'flash') {
media.addEventListener('canplay', function() {
// Player is ready
media.play();
}, false);
} else {
media.play();
}
var force = setInterval(function() {
if (media.paused) {
media.play();
} else if (media.paused === false) {
clearInterval(force);
}
}, 500);
};
});
@TiagoDanin
Copy link

Very good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment