" player.textTracks未定义"与video.js vtt-thumbnails

时间:2015-12-24 10:23:16

标签: video video.js

我正在尝试为video.js使用vtt-thumbnails插件,但无论是在我的网站上还是在演示中,我都会遇到此错误:

  

TypeError:player.textTracks(...)未定义

我正在使用5.4.4,我的代码看起来像这样:

<script src="/videojs/video.js"></script>
<link href="/videojs/default.css" rel="stylesheet">
<script src="/videojs/videojs.thumbnails.js"></script>
<link href="/videojs/videojs.thumbnails.css" rel="stylesheet">

<video id="thevideo" class="video-js vjs-default-skin"  preload="auto" controls="controls" autoplay loop poster="poster.jpg">
<source src="file.mp4" type="video/mp4" />
<track kind="metadata" src="vtt.php" default>
</video>

<script>
// initialize video.js
var video = videojs('thevideo',{plugins:{thumbnails{width:120,height:90}}});
<script>

有什么想法吗?

ps:我的.vtt文件已经可以正常使用Jwplayer。*

1 个答案:

答案 0 :(得分:6)

此插件是在video.js 5.x发布之前编写的。版本4.x的一个变化是插件现在加载更早。因此,此插件现在试图过早访问文本轨道。您可以通过初始化ready函数中的插件来解决这个问题,而不是将其作为设置选项传递:

var video = videojs('thevideo', {}, function(){
  this.thumbnails({width:120,height:90});
});