美文网首页
H5 Video 禁止快进

H5 Video 禁止快进

作者: lemon1837 | 来源:发表于2018-05-29 09:56 被阅读0次
<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title>H5 Video禁止快进</title>
        </style>
    </head>

    <body>
        <div>
            <video id="my-video" controls preload="meta" height="70%" width="100%" data-setup="{}">
                <source src="http://jq22com.qiniudn.com/jq22-sp.mp4" type="video/mp4">
            </video>
        </div>
        <script type="text/javascript">
        var video = document.getElementById("my-video");
        var last = 0;
        //当目前的播放位置已更改时
        video.ontimeupdate = function () {
            var current = video.currentTime;
            if(current - last > 2) {
                video.currentTime = last;
            } else {
                last = current;
            }
        };
        //播放完毕时
        video.onended = function () {
            alert("播放完毕");
        }
        </script>
    </body>

</html>

相关文章

网友评论

      本文标题:H5 Video 禁止快进

      本文链接:https://www.haomeiwen.com/subject/zheojftx.html