jQuery:在悬停时播放视频

时间:2017-08-31 20:11:25

标签: jquery html5-video

寻找比这更好的解决方案:

$(".video-post").hover(function () {    
  $(this).find("video").get(0).play();
}, function () {
   $(this).find("video").get(0).pause();     
}); 

- >它工作但导致铬错误: DOMException:play()请求被pause()调用中断。

有一些关于此的文章,但似乎无法找到任何简单的答案。 https://developers.google.com/web/updates/2017/06/play-request-was-interrupted

1 个答案:

答案 0 :(得分:0)

尝试:

$(document).ready(function () {
    $(".video-post").hover(function () {
       $(this).find("video")[0].play();
    }, function () {
        var el = $(this).find("video")[0];
        el.pause();
        el.currentTime = 0;
    });
});
相关问题