Hello I have a simple Javascript code to append a video transcription into a div using Video.js
and videojs-transcript
. It works fine in Firefox but in Google Chrome when the transcription is too long it appends less than half of it. Also when I refresh it stops every time in different node.
A simple test code to produce the bug:
<head>
<script src="https://vjs.zencdn.net/4.12/video.js"></script>
<script src="https://walsh9.github.io/videojs-transcript/dist/videojs-transcript.js"></script>
</head>
<body>
<video id="video" crossorigin="anonymous">
<source src="https://pvclouddev.blob.core.windows.net/filescontainer/15TestLarge_1587760757304.mp4" type="video/mp4">
<track kind="captions" src="https://pvclouddev.blob.core.windows.net/filescontainer/790d31e9-d38d-48f4-87d5-9e9959acc39a.vtt" srclang="en" label="English" default>
</video>
<div id="transcript"></div>
<script>
var video = videojs('video').ready(function(){
// Set up any options.
var options = {
showTitle: false,
showTrackSelector: false,
};
// Initialize the plugin.
var transcript = this.transcript(options);
// Then attach the widget to the page.
var transcriptContainer = document.querySelector('#transcript');
transcriptContainer.appendChild(transcript.el());
});
</script>
</body>
Edit: In the videojs-transcript
file when I try to alert(cues.length)
in createTranscriptBody
function it shows much less than what I got in Firefox.
Edit 2: I found out that the problem is with the method createTranscriptBody
in videojs-transcript.js
. It starts adding cues to the div before the vtt file is totally loaded. Is there any way to make it wait for the vtt to get fully loaded without using the timeout?