HTML5视频通话时的暂停和播放事件

问题描述 投票:0回答:1

以此页为例:

<!doctype html>

<html>
    <body>
        <video id="video" controls width="500" muted="muted" >   
            <source src="https://file-examples.com/wp-content/uploads/2017/04/file_example_MP4_1920_18MG.mp4" type="video/mp4"/>  
        </video>
        <script type="text/javascript">
            var vid=document.getElementById('video')

            vid.onpause=function(){
                console.log('on pause executed')
            }

            vid.onplay=function(){
                console.log('on play executed')
            }
        </script>
    </body>
</html>

[如果我在播放视频的同时进行搜索,那么这两者都会显示在控制台中。如果我在视频暂停期间进行搜索,则都不会显示在控制台中。我该如何做,以便仅在用户显式暂停/播放视频时才调用这些功能?

javascript html html5-video media-player html5-audio
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.