javascript 从 youtube 向 yt.player 对象添加其他参数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19241151/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Adding additional parameters to the yt.player object from youtube
提问by Himmators
I'm initiating a youtube video using yt.player like this:
我正在使用 yt.player 启动一个 youtube 视频,如下所示:
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '720',
width: '1280',
html5: 0,
videoId: 'i8IXMGHpGBk',
events: {
'onStateChange': function(e) {
if (e.data == 0) {
//skrolla h?r
}
}
}
});
}
When adding a video using the embed-code, I can add a multitude of other parameters, like these: controls=0&modestbranding=1&showinfo=0&autoplay=1
使用嵌入代码添加视频时,我可以添加许多其他参数,例如:controls=0&modestbranding=1&showinfo=0&autoplay=1
When i try to add autoplay for example I tried this:
例如,当我尝试添加自动播放时,我尝试了以下操作:
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '720',
width: '1280',
html5: 0,
videoId: 'i8IXMGHpGBk',
autoplay: 1,
events: {
'onStateChange': function(e) {
if (e.data == 0) {
//skrolla h?r
}
}
}
})
but it doesn't work. What am I doing wrong?
但它不起作用。我究竟做错了什么?
回答by codebreaker
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '720',
width: '1280',
videoId: 'i8IXMGHpGBk',
playerVars: { 'autoplay': 1, 'controls': 1,'autohide':1,'wmode':'opaque' },
events: {
'onStateChange': function(e) {
if (e.data == 0) {
//skrolla h?r
}
}
}
})
try this code and reply me on this...
试试这个代码并回复我这个......