我编写了jQuery代码来暂停和播放视频。在这里,我使用了embed
标记(不是video
标记)。它适用于Chrome,但不适用于Firefox。
jQuery( document ).ready(function(){
jQuery( document ).scroll(function() {
jQuery(".entry-content .wonderplugingallery").each(function(index){
var eTop = jQuery('.entry-content .html5gallery-container-'+index).offset().top;
var topy = eTop - jQuery(window).scrollTop();
if(topy>80 && topy<340){
jQuery(".html5gallery-container-"+index+" .html5gallery-video-play-"+index).trigger("click");
jQuery(".html5gallery-container-"+index+" .html5boxPlayPause .html5boxPlay").trigger("click");
}else{
jQuery(".html5gallery-container-"+index+" .html5boxPlayPause .html5boxPause").trigger("click");
}
});
});
});
答案 0 :(得分:-1)
参考此链接中的代码和实例[/ p>
How to pause html5 video when out of view code (non-statically positioned)
parent = video;
while (parent && parent !== document.body) {
x += parent.offsetLeft;
y += parent.offsetTop;
parent = parent.offsetParent;}