-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow displaying of multiple text tracks at once (#5817)
This allows the user to display multiple tracks when `allowMultipleShowingTracks` is passed to the `TextTrackDisplay`. Currently, multiple tracks must be shown programmatically and cannot be done via the subtitles menus. In addition, this adds two new classes to cue elements: `vjs-text-track-cue` and `vjs-text-track-cue-${track.language}`. This allows easier targetting with CSS. Example usage: ```js var player = videojs('example-video', { textTrackDisplay: { allowMultipleShowingTracks: true } }); ``` Fixes #5798.
- Loading branch information
Showing
2 changed files
with
129 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Video.js Text Descriptions, Chapters & Captions Example</title> | ||
|
||
<!-- Load the source files --> | ||
<link href="../dist/video-js.css" rel="stylesheet" type="text/css"> | ||
<script src="../dist/video.js"></script> | ||
|
||
<!-- Set the location of the flash SWF --> | ||
<script> | ||
videojs.options.flash.swf = '../node_modules/videojs-flash/node_modules/videojs-swf/dist/video-js.swf'; | ||
</script> | ||
|
||
</head> | ||
<body> | ||
|
||
<!-- NOTE: we have to disable native Text Track support for the HTML5 tech, | ||
since even HTML5 video players with native Text Track support | ||
don't currently support 'description' text tracks in any | ||
useful way! Currently this means that iOS will not display | ||
ANY text tracks --> | ||
<video id="example_video_1" class="video-js" controls preload="none" width="640" height="360" | ||
poster="//d2zihajmogu5jn.cloudfront.net/elephantsdream/poster.png"> | ||
|
||
<source src="//d2zihajmogu5jn.cloudfront.net/elephantsdream/ed_hd.mp4" type="video/mp4"> | ||
<source src="//d2zihajmogu5jn.cloudfront.net/elephantsdream/ed_hd.ogg" type="video/ogg"> | ||
|
||
<track kind="captions" src="../docs/examples/elephantsdream/captions.en.vtt" srclang="en" label="English" default> | ||
<track kind="captions" src="../docs/examples/elephantsdream/captions.sv.vtt" srclang="sv" label="Swedish"> | ||
<track kind="captions" src="../docs/examples/elephantsdream/captions.ru.vtt" srclang="ru" label="Russian"> | ||
<track kind="captions" src="../docs/examples/elephantsdream/captions.ja.vtt" srclang="ja" label="Japanese"> | ||
<track kind="captions" src="../docs/examples/elephantsdream/captions.ar.vtt" srclang="ar" label="Arabic"> | ||
|
||
<track kind="descriptions" src="../docs/examples/elephantsdream/descriptions.en.vtt" srclang="en" label="English"> | ||
|
||
<track kind="chapters" src="../docs/examples/elephantsdream/chapters.en.vtt" srclang="en" label="English"> | ||
|
||
<p class="vjs-no-js">To view this video please enable JavaScript, and consider upgrading to a web browser that <a href="https://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a></p> | ||
</video> | ||
<script> | ||
var vid = document.getElementById('example_video_1'); | ||
var player = videojs(vid, { | ||
textTrackDisplay: { | ||
allowMultipleShowingTracks: true | ||
} | ||
}); | ||
|
||
player.on('loadedmetadata', function() { | ||
player.textTracks()[0].mode = 'showing'; | ||
player.textTracks()[1].mode = 'showing'; | ||
player.textTracks()[2].mode = 'showing'; | ||
player.textTracks()[3].mode = 'showing'; | ||
player.textTracks()[4].mode = 'showing'; | ||
}); | ||
</script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters