Videojs TypeError:this.addEvent不是函数

时间:2013-05-20 10:53:49

标签: video.js

真的不知道我的代码有什么问题!我试着通过我的firefox控制台中的错误来将结束事件附加到我的播放器:

“TypeError: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>
你可以帮帮我吗? 非常感谢

1 个答案:

答案 0 :(得分:15)

video.js最近已更新至版本4,并且API中的一些内容已更改。您需要使用myPlayer.on("ended", videoEnd);

API文档:https://github.com/videojs/video.js/blob/master/docs/api/vjs.Player.md

相关问题