<html>
<head>
<link href="video-js/video-js.css" rel="stylesheet" />
</head>
<body>
<video
id="my-video1"
class="video-js"
controls
preload="auto"
width="640"
height="264"
poster="MY_VIDEO_POSTER.jpg"
data-setup="{}"
>
<source src="MY_VIDEO.mp4" type="video/mp4" />
<p class="vjs-no-js">
To view this video please enable JavaScript, and consider upgrading to a
web browser that
<a href="https://videojs.com/html5-video-support/" target="_blank"
>supports HTML5 video</a
>
</p>
</video>
<p></p>
<p></p>
<video
id="my-video2"
class="video-js"
controls
preload="auto"
width="640"
height="264"
poster="MY_VIDEO_POSTER.jpg"
data-setup="{}"
>
<source src="MY_VIDEO.mp4" type="video/mp4" />
<p class="vjs-no-js">
To view this video please enable JavaScript, and consider upgrading to a
web browser that
<a href="https://videojs.com/html5-video-support/" target="_blank"
>supports HTML5 video</a
>
</p>
</video>
<script src="video-js/video-js.js"></script>
<script>
var options = {
muted: true,
controls:false
};
function onPlayerReady() {
videojs.log('播放器已经准备好了!');
this.on('ended', function() {
videojs.log('播放结束了!');
});
let that=this;
this.on('click',function() {
videojs.log('click!');
})
this.on('mouseover',function() {
videojs.log('mouseover!');
that.play();
});
this.on('mouseout',function() {
videojs.log('mouseout!');
that.pause();
})
}
var player = videojs('my-video1', options,onPlayerReady );
var player2 = videojs('my-video2', options,onPlayerReady );
</script>
</body>
</html>