1

Looking for a solution which is written in pure JS. It will be used as an integration into a web page.

P.S. Another reference. Here is some example for Video.js Is there any way to get current caption's text from video tag using Video.js?

...but I still need it in pure JS.

Also, used this example:

(function(){

    var video = document.querySelector('video');
    var span = document.querySelector('span');

    if (!video.textTracks) return;

    var track = video.textTracks[0];
    track.mode = 'hidden';

    track.oncuechange = function(e) {

        var cue = this.activeCues[0];
        if (cue) {
            span.innerHTML = '';
            span.appendChild(cue.getCueAsHTML());
        }

    };
})()

...but "track.oncuechange" never happened.

Kirby
  • 2,847
  • 2
  • 32
  • 42

0 Answers0