问题
I'm initiating a youtube video using yt.player like this:
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
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?
回答1:
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...
来源:https://stackoverflow.com/questions/19241151/adding-additional-parameters-to-the-yt-player-object-from-youtube