最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Video.js Auto loading subtitlescaptions - Stack Overflow

programmeradmin0浏览0评论

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'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.

Share Improve this question asked Sep 30, 2013 at 21:07 user2832704user2832704 411 silver badge8 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

I got the solution. You can check it at github, https://github./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./testdrive/Graphics/CaptionMaker/

Documentation

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

发布评论

评论列表(0)

  1. 暂无评论