本文介绍了Youtube Javascript API - 禁用相关视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是的,这似乎记录得很差,或者我在文档中看不到它.我基本上不想要使用 JavaScript API 的相关视频 (?rel=0).

Right, this seems to be poorly documented or I can't see it in the documentation. I basically want no related videos (?rel=0) using the JavaScript API.

$players[$vidIdPlaceholderRef] = new YT.Player('player_' + $vidIdPlaceholderRef, {
    height: '550',
    width: '840',
    videoId: $vidId
});

是我所拥有的.

我也试过了:

$players[$vidIdPlaceholderRef] = new YT.Player('player_' + $vidIdPlaceholderRef, {
    height: '550',
    width: '840',
    videoId: $vidId + '?rel=0',
    rel : 0
});

没有运气.有谁知道可以添加的选项(尝试 rel : 0 没有运气)

with no luck. Does any one know of an option which can be added (tried rel : 0 with no luck )

推荐答案

rel"是一个播放器参数,在这里指定:

"rel" is a player parameter, as specified here:

https://developers.google.com/youtube/player_parameters#rel

要将播放器参数添加到 iframe 播放器,您需要指定第二个构造函数参数的 playerVars 属性(在撰写本文时已记录在 此处,以及 IFrame API 文档页面)

To add player parameters to iframe players, you need to specify the playerVars property of the second constructor argument (at the time of writing this is documented here, and on the IFrame API documentation page)

例如

new YT.Player('playerid', {
    height: '550',
    width: '840',
    videoID: 'video_id',
    playerVars: {rel: 0, showinfo: 0, ecver: 2}
});

这篇关于Youtube Javascript API - 禁用相关视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 05:38