有什么方法可以使用Video.js从视频标签中获取当前字幕的文本吗? [英] Is there any way to get current caption's text from video tag using Video.js?

查看:1213
本文介绍了有什么方法可以使用Video.js从视频标签中获取当前字幕的文本吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在播放视频时获取当前字幕的文本(而不是实现自己的字幕块(即隐藏原始字幕),并以几种不同的方式使用信息).目前,我为播放器使用 videojs .有什么办法可以从中获取当前字幕的字符串?

I want to get current subtitles' text during playing a video (and than implement own subtitles block (i.e. to hide original) and also use the information in a few different ways). Currently I use videojs for my player. Is there any way to get current caption's string from it?

推荐答案

解决方案:

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

        var aTextTrack =  this.textTracks()[0];
        aTextTrack.on('loaded', function() {
            console.log('here it is');
            cues = aTextTrack.cues();   //subtitles content is here
            console.log('Ready State', aTextTrack.readyState()) 
            console.log('Cues', cues);
        });

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


结果:


Result:

PS.在此处找到代码.

这篇关于有什么方法可以使用Video.js从视频标签中获取当前字幕的文本吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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