VideoJs TextTracks提示为空 [英] VideoJs TextTracks Cues empty

查看:237
本文介绍了VideoJs TextTracks提示为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有以下代码:

  videojs(example_video_1,{},function(){
//播放器(this)被初始化并准备就绪
var aTextTrack = this .textTracks()[0];

aTextTrack.show();
var theArray = this.textTracks()[0] ['$'];
console.log (theArray);
console.dir(this.textTracks()[0] ['$']);
//例子:开始播放视频。
this.play();

});


var theArray打印为空,但是console.dir打印数组的内容。我如何获得这些值?我知道它与javascript asyc变量有关。

干杯

这是正确的答案。它花了我一段时间来破解它,因为videoJS上没有太多文档

  videojs(example_video_1,{},function (){
// Player(this)被初始化并准备就绪。
var aTextTrack = this.textTracks()[0];
aTextTrack.on('loaded',function(){
console.log('here is');
cues = aTextTrack.cues();
console.log('Ready State',aTextTrack.readyState())
console.log('cues',cues);
});

aTextTrack.show(); //此方法调用触发字幕加载和加载触发
this.play();

});


I need to be able to get the Cues array from TextTracks object in VideoJs.

I have the following code:

videojs("example_video_1", {}, function(){
   // Player (this) is initialized and ready.
    var aTextTrack =  this.textTracks()[0];

    aTextTrack.show();
    var theArray = this.textTracks()[0]['$'];
    console.log(theArray);
    console.dir(this.textTracks()[0]['$']);
    // EXAMPLE: Start playing the video.
    this.play();

}); 

The var theArray prints as empty but console.dir prints the contents of the Array. How can I get these values? I know its related with javascript asyc variables.

Cheers

解决方案

This is the right answer. It took me a while to hack it as there is not much documentation on videoJS

videojs("example_video_1", {}, function(){
    // Player (this) is initialized and ready.
    var aTextTrack =  this.textTracks()[0];
    aTextTrack.on('loaded', function() {
            console.log('here it is');
            cues = aTextTrack.cues();
            console.log('Ready State', aTextTrack.readyState()) 
            console.log('Cues', cues);
    });

    aTextTrack.show();//this method call triggers the subtitles to be loaded and loaded trigger
    this.play();

});

这篇关于VideoJs TextTracks提示为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆