Zinglish
Zinglish

Reputation: 345

Vimeo force CC language

Trying to embed a Vimeo video into my website and I have put about 5 different languages into the CC of the video on Vimeo. However I don't want the user to have to change their language in the CC drop down in the Vimeo embed, I would like to assign it in HTML/JavaScript (using geolocation to select their base language) then they can change their CC language accordingly once the video has started playing.

Upvotes: 0

Views: 3405

Answers (2)

Sam Vloeberghs
Sam Vloeberghs

Reputation: 912

You can use the enableTextTrack function on a player initialized by the JS API provided by Vimeo:

// Select with the DOM API
var iframe = document.querySelector('iframe');
var iframePlayer = new Vimeo.Player(iframe);

player.enableTextTrack('en').then(function(track) {
    // track.language = the iso code for the language
    // track.kind = 'captions' or 'subtitles'
    // track.label = the human-readable label
}).catch(function(error) {
    switch (error.name) {
        case 'InvalidTrackLanguageError':
            // no track was available with the specified language
            break;

        case 'InvalidTrackError':
            // no track was available with the specified language and kind
            break;

        default:
            // some other error occurred
            break;
    }
});

More information on the github of Vimeo player JS API: https://github.com/vimeo/player.js#enabletexttracklanguage-string-kind-string-promiseobject-invalidtracklanguageerrorinvalidtrackerrorerror

Upvotes: 2

Brad Dougherty
Brad Dougherty

Reputation: 920

We don't have this yet, but we do plan on offering some way to do it with an embed parameter and through the JavaScript API in the future.

Upvotes: 0

Related Questions