Last active
August 29, 2015 14:21
-
-
Save sethrubenstein/a5a3e0ae19dfe5b94ba6 to your computer and use it in GitHub Desktop.
Play WordPress video shortcodes when in viewport. Requires isInViewport plugin.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(function() { | |
jQuery(window).scroll(function() { | |
jQuery('.wp-video-shortcode').each(function() { | |
var str = jQuery(this).attr('id'); | |
var arr = str.split('_'); | |
typecheck = arr[0]; | |
if (jQuery(this).is(":in-viewport( 400 )") && typecheck == "mep") { | |
mejs.players[jQuery(this).attr('id')].media.play(); | |
} else if (typecheck == "mep") { | |
mejs.players[jQuery(this).attr('id')].media.stop(); | |
} | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment