使用 Safari 隐藏视频文本轨道 [英] Hiding a video text track with Safari
问题描述
此方法适用于 Firefox/Chrome,但不适用于 Safari
Using this method works on Firefox/Chrome but not with Safari
let videoElement = document.querySelector(`#my-video`);
let track = videoElement.textTracks[0];
track.mode = 'hidden';
我也试过 ::cue
css 选择器
I have also tried the ::cue
css selector
::cue {
visibility: hidden;
}
这会隐藏文本本身,但不会隐藏半透明的黑色背景.
This hides the text itself but not the semi-transparent black background.
我需要在其他地方渲染内容时保持文本跟踪,但我不希望它在视频中重复.
I need to keep the text track as I am rendering the content elswhere, but I don't want it repeated over the video.
有没有办法做到这一点,我错过了什么?
Is there a way to do this, have I missed something?
推荐答案
将您的曲目 kind
设置为 metadata
.
Set your track kind
to metadata
.
无论如何,这就是您使用曲目的方式,因此这将是最合适的.作为奖励,这种 kind
的曲目不会显示给用户,因此无需其他操作.
Since that's how you're using the track anyway, this would be the most appropriate. As a bonus, tracks of this kind
are not displayed to the user so there's nothing else to do.
另见:https://developer.mozilla.org/en-US/docs/Web/HTML/Element/track
这篇关于使用 Safari 隐藏视频文本轨道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!