
Working with Text Tracks Showing Tracks ProgrammaticallyĬertain use cases call for turning captions on and off programmatically rather than forcing the user to do so themselves.

This is considered a security concern by the spec. This is because some browsers apply the crossorigin attribute to the video source itself and not just the tracks. One thing to be aware of is that the video files themselves will also need CORS headers. Most users will want to use "anonymous" with cross-origin tracks: This attribute has two possible values "anonymous" and "use-credentials". In addition to enabling CORS, you will need to add the crossorigin attribute to the video element itself. If you'd like to have a player served from one domain, but the text track served from another, you'll need to enable CORS on the server that is serving your text tracks. Text Tracks from Another Domainīecause Video.js loads the text track file via JavaScript, the same-origin policy applies. "en" for English or "es" for Spanish.įor supported language translations, please see the languages folder (/lang) folder located in the Video.js root and refer to the languages guide for more information on languages in Video.js.

#Caption definition for kids code#
The valid BCP 47 code for the language of the text track, e.g. Note: For chapters, default is required if you want the chapters menu to show. Otherwise, the viewer would need to select their language from a captions or subtitles menu. The boolean default attribute can be used to indicate that a track's mode should start as "showing". For example, in a menu for selecting a captions language. Short descriptive text for the track that will used in the user interface. "metadata": Tracks that have data meant for JavaScript to parse and do something with.Descriptions are read by a screen reader or turned into a separate audio track.


For that reason, we recommend only using remote text tracks. This is a convenient term for tracks that have an associated element rather than those that do not.Įither can be created programmatically, but only remote text tracks can be removed from a player. Video.js refers to so-called "remote" text tracks. Video.js offers a cross-browser implementation of text tracks. Text tracks are a feature of HTML5 for displaying time-triggered text to the end-user.
