gpt4 book ai didi

video.js - Videojs TypeError : this. addEvent 不是函数

转载 作者:行者123 更新时间:2023-12-01 07:14:30 24 4
gpt4 key购买 nike

真的不知道我的代码有什么问题!我正在尝试将结束事件附加到我的播放器,因为我在我的 Firefox 控制台中收到此错误:

“类型错误:this.addEvent 不是函数”

我尝试了很多方法,但都没有解决这个问题!

<!DOCTYPE html>
<html>
<head>
<link href="video-js.css" rel="stylesheet" type="text/css">
<script src="video.js"></script>
<script>_V_.options.flash.swf = "video-js.swf";</script>
</head>
<body>
<video id="example_video_1" class="video-js vjs-default-skin" controls preload="none" width="400" height="500" data-setup='{}'
poster="http://video-js.zencoder.com/oceans-clip.png">
<source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4' />
<source src="http://video-js.zencoder.com/oceans-clip.webm" type='video/webm' />
<source src="http://video-js.zencoder.com/oceans-clip.ogv" type='video/ogg' />
<track kind="captions" src="demo.captions.vtt" srclang="en" label="English" />
</video>
<script>
var myPlayer = videojs("example_video_1");

videojs("example_video_1").ready(function(){
var myPlayer = this;

var videoEnd = function(){
console.log('ended')
};

myPlayer.addEvent("ended", videoEnd);

});
</script>
</body>
</html>

你能帮我吗?
多谢

最佳答案

video.js 最近更新到第 4 版,API 中的一些内容也发生了变化。您需要使用 myPlayer.on("ended", videoEnd);
API 文档:https://github.com/videojs/video.js/blob/master/docs/api/vjs.Player.md

关于video.js - Videojs TypeError : this. addEvent 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16647942/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com