有没有办法从视频标签中获取当前标题的文本? [英] Is there any way to get current caption's text from video tag?

查看:850
本文介绍了有没有办法从视频标签中获取当前标题的文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在播放视频期间获取当前字幕的文本(并且实现自己的字幕块(即隐藏原始字幕)并且还以几种不同的方式使用该信息)。目前,我为我的播放器使用






PS。代码此处


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?

解决方案

Solution:

    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. Code found here.

这篇关于有没有办法从视频标签中获取当前标题的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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