Vimeo力量CC语言 [英] Vimeo force CC language

查看:182
本文介绍了Vimeo力量CC语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试将Vimeo视频嵌入到我的网站中,我已经在Vimeo的视频CC中加入了大约5种不同的语言.但是我不希望用户必须在Vimeo嵌入的CC下拉菜单中更改其语言,我想以HTML/JavaScript进行分配(使用地理位置选择其基本语言),然后他们可以更改其CC语言视频开始播放后,相应地进行相应操作.

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.

推荐答案

您可以在由Vimeo提供的JS API初始化的播放器上使用enableTextTrack函数:

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;
    }
});

有关Vimeo播放器JS API的github的更多信息:

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

这篇关于Vimeo力量CC语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆