gpt4 book ai didi

javascript - 如何在 video.js 中设置字幕

转载 作者:行者123 更新时间:2023-11-29 10:39:47 25 4
gpt4 key购买 nike

大约 3 小时前我在互联网上搜索,我很困惑如何在 video.js 播放器中实现字幕。

我已经添加了<track kind="subtitles" src="http://test.to/the-longest-ride.720p.BluRay.x264.YIFY.srt" srclang="en-US" label="English"></track>我的播放器中的这段代码并将此字幕文件上传到我的服务器评论气球已经出现在我的播放器菜单中,但没有显示字幕。

当我搜索时,我读到 webvtt 格式将运行 :( 但是关于 srt 格式或其他格式以及在运行时我将如何在 webvtt 格式上实现和转换。

我也明白了 Video Js Caption Plugin我已阅读此文档,但我不太了解在哪里提供副标题链接。

请帮助如何添加字幕以及我应该从哪里开始。

谢谢

最佳答案

我想提一下另一种以编程方式将轨道添加到 video.js 的方法:

var videoOptions = {
controls: true,
responsive: true,
autoplay: true,
preload: 'metadata',
sources: [{src: 'https://domain/myfile.m3u8', type: 'application/x-mpegURL'}],
tracks: [{src: 'https://domain/mysub.vtt', kind:'captions', srclang: 'en', label: 'English'}]
}
// create the player using the above options
videojs('my-player', videoOptions);

您还可以在创建播放器后添加/删除/选择播放器轨道,如说明here .

关于javascript - 如何在 video.js 中设置字幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31284568/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com