我正在使用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
}
}
}
});
}
使用嵌入代码添加视频时,我可以添加许多其他参数,例如:控件=0&模式品牌=1&显示信息=0&自动播放=1
例如,当我尝试添加自动播放时,我尝试了以下方法:
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
}
}
}
})
但它不起作用。我做错了什么?
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
}
}
}
})
试试这段代码并回复我...