سؤال

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?

هل كانت مفيدة؟

المحلول

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...

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top