问题描述
我正在尝试在视频html中添加外部来源的字幕,但我不能。我正在使用WebTorrent技术,因此,我在浏览器中播放视频种子,< track>
标记对我不起作用。以下是我使用的代码:
字幕的代码就是这样:
I'm trying to add subtitles from an external source in a video html but I can't. I'm using the WebTorrent Technology, so, I'm streaming video torrents in my Browser and the <track>
tag not works for me. Here's the code that I use: https://plnkr.co/edit/31RZSBETaAQgnCgZgKUt?p=preview
The code for subtitles it's this:
file.appendTo('body');
var video = document.querySelector("video");
var track = video.addTextTrack("subtitles", "prompt", "en");
track.mode = "showing";
});
谢谢,我希望你能帮助我!
Thanks, i hope that you can help me!
推荐答案
您可以在HTML中创建或包含< track>
元素作为父< video> 元素默认
属性设置为 true
, src
到 .vtt
文件,种类
设置为字幕
,模式
设置为显示
, label
设置为Español
, srclang
设置为es
You can create or include a <track>
element within HTML as a child of parent <video>
element with default
property set to true
, src
to to .vtt
file, kind
set to "subtitles"
, mode
set to "showing"
, label
set to "Español"
, and srclang
set to "es"
file.appendTo('body');
var video = document.querySelector("video");
var track = document.createElement("track");
track.mode = "showing";
track.label = "Español";
track.kind = "subtitles";
track.srclang = "es";
track.src = "subs.vtt";
track.default = true;
video.appendChild(track);
plnkr
这篇关于如何在HTML5中添加外部源的字幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!