質問

I'm doing a website and I need to show a player and I came out with video.js but I have a question how can I put my subtitles showing up without the user needing to click on anything?

This is my code:

<video id="filme" class="video-js vjs-default-skin" controls preload="auto" width="100%" height="640" data-setup='{}'>
    <source src="./video.mp4" type='video/mp4' />
    <track kind="subtitles" src="./subs/subtitles.srt" srclang="pt" label="Português" default>
</video>

I hope you can help me.

Thanks in advance.

役に立ちましたか?

解決

I got the solution. You can check it at github, https://github.com/videojs/video.js/issues/656

This is the code that you should update on line 6666 and after. Add this code:

if(track.dflt()) {
  this.player_.showTextTrack(this.track.id_, this.track.kind());
}

After this: (line 6676, as of v4.3)

 this.player_.on(track.kind() + 'trackchange', vjs.bind(this, this.update));

I hope this helps someone.

他のヒント

According to the Video.js documentation...

Timed text requires a text file in WebVTT format.

Your current track is referencing an .srt file.

Try changing it to a WebVTT.

There is a builder here: http://ie.microsoft.com/testdrive/Graphics/CaptionMaker/

Documentation

http://www.videojs.com/docs/tracks/

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top