ryan297
ryan297

Reputation: 1

MediaElement.js - Default video captions to On?

Is there a way to configure the MediaElement.js video player so the captions would be on by default? Thanks.

Upvotes: 0

Views: 3037

Answers (2)

Justin Putney
Justin Putney

Reputation: 752

Looks like it's also possible to do this after the fact, and with isolated videos, with the setTrack function.

var valueOfCaptionsInputElement = 'en';
player.setTrack(valueOfCaptionsInputElement);

Source: https://github.com/mediaelement/mediaelement/blob/master/docs/usage.md#captions

Update: The documentation suggested the id of input element, but in looking at the source code of my version, value was used, so I adjusted and the above code worked for me.

Upvotes: 0

user3564964
user3564964

Reputation: 11

There is a parameter startLanguage which appears to default the captions to the specified language and switch them on. Works for me, but doesn't appear to be heavily documented. Only mention on the mediaelementjs site is in the example for Auto-Translation of track elements.

Syntax is:

$('video').mediaelementplayer({
    // other media element settings.....
    // start with English automatically turned on
    startLanguage: 'en'
});

Upvotes: 1

Related Questions