TV Remote with Lang and Subtitle Buttons

Subtitles by DEFAULT

12/18/2020December 18, 2020(over 2 years ago)
2 min read
12/18/2020December 18, 2020(over 2 years ago)
2 min read

Subtitles by DEFAULT

Earlier this year we announced support for subtitles and captions and described some of the magic flags for controlling their behavior. If you saw that “we’ll be giving you more control over the DEFAULT flag later this year” and have been holding your breath for the follow-up, you can finally breathe again!

A quick recap of the DEFAULT flag from those previous blogs: it “indicates that this track must be played by default, unless the user overrides this.”  So it’s especially useful  to enable captions on autoplaying video that is muted.

Mux now supports setting the DEFAULT flag to “YES” on a caption or subtitle track through playback modifiers that can be added to the manifest URL:{PLAYBACK_ID}.m3u8?default_subtitles_lang=en-AU

Because this feature only affects manifests, it already works with all existing assets! Like other playback modifiers, it can be included as a claim inside the JWT body for signed URLs too:

 "exp": 1599583520,
 "aud": "v",
 "sub": "{PLAYBACK_ID}",
 "default_subtitles_lang": "en-AU" 

Most players handle this automatically so long as autoplay is enabled and the track has DEFAULT set to “YES”. Here’s a simple Video.js example:

  <link href="" rel="stylesheet" />

    id="muted-autoplay" width=640 height=360 class="vjs-default-skin"
    controls muted autoplay playsInline

  <script src=""></script>
      var player = videojs('muted-autoplay');

Language SelectionLink to Language Selection

Just like when creating a subtitle track, Mux accepts BCP-47 language codes for selecting a default subtitle language. Most often you would simply match the language your page or UI is presenting.

If there’s no exact match on the asset, we’ll try to find the closest match of the same language. This helps with regional variations as well as being a bit more flexible.

With a video that has US and UK subtitles…


then ?default_subtitles_lang=en will return the US version:

00:45.200 --> 00:49.670
I organized my neighbors for a viewing at the theater.

and ?default_subtitles_lang=en-AU will match to the UK version:

00:45.200 --> 00:49.670
I organised my neighbours for a viewing at the theatre.

Try it OutLink to Try it Out

The Video.js example above is copied into this Code Sandbox, updated with your favorite test video. Give it a try, and as always, let us know if you have any questions or feedback.

Create an account

No credit card to start. $20 in free credits when you're ready.

Get started free

Subscribe to the Mux newsletter