最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How To Disable Youtube Captions in a Youtube Embed Link - Stack Overflow

programmeradmin4浏览0评论

When creating an embed link on youtube the Captions are on by default. Is there a way to disable to the captions or turning them off when embedding a youtube link?

The documentation indicates:

Make captions automatically appear for an embedded video by adding "&cc_load_policy=1" to the video's embed code.

And I need to it the other way around. I tried to use &cc_load_policiy=0 but that didn't work. I also found this question but none of the answers seem to work.

I am using also VideoJS. So maybe there is a way to do it through it...

Thanks

When creating an embed link on youtube the Captions are on by default. Is there a way to disable to the captions or turning them off when embedding a youtube link?

The documentation indicates:

Make captions automatically appear for an embedded video by adding "&cc_load_policy=1" to the video's embed code.

And I need to it the other way around. I tried to use &cc_load_policiy=0 but that didn't work. I also found this question but none of the answers seem to work.

I am using also VideoJS. So maybe there is a way to do it through it...

Thanks

Share Improve this question edited May 23, 2017 at 12:34 CommunityBot 11 silver badge asked Apr 14, 2014 at 20:42 special0nespecial0ne 6,26318 gold badges68 silver badges107 bronze badges 1
  • I figured out a small workaround for no captions in some browsers, just in case you still need it... – Armfoot Commented May 19, 2015 at 9:40
Add a comment  | 

3 Answers 3

Reset to default 15

Use the same logic as for iv_load_policy and set value to 3:

For example:

<iframe width="560" height="315" src="https://www.youtube.com/embed/WJo98LfIfEA?cc_load_policy=3" frameborder="0" allowfullscreen></iframe>

Also it works great with JS API for embedded videos.

Even with cc_load_policy and iv_load_policy off some videos still show the captions... There is a way to disable it completelly unloading the captions module:

player = new YT.Player('player', {
    width: "auto",
    height: "auto",
    playerVars: {

    ...

})

function onPlayerStateChange(event) {
    if (event.data == YT.PlayerState.PLAYING) {

        ...

        try {
            // Disable captions completelly
            player.unloadModule("captions");
            player.unloadModule("cc");
        } catch (exception) { }
    }
}

cc_load_policy (supported players: AS3, AS2) Values: 1. Default is based on user preference. Setting to 1 will cause closed captions to be shown by default, even if the user has turned captions off.

Reference

Unfortunately I don't think this is possible as it's a user-preference. The cc_load_policy refers to disabling/enabling the toggle button for the player (limited to AS3, AS2 players). And since VideoJS is based off HTML5, I'm imagining the cc_load_policy isn't available for your use either.

发布评论

评论列表(0)

  1. 暂无评论