Skip to content Skip to sidebar Skip to footer

Autoplay Multiple YouTube Videos On Mute At Once

I am trying to make a webpage that uses the YouTube iframe API to display multiple videos which start playing automatically on load. I want 3 of the 4 videos to start playing in mu

Solution 1:

Kindly change your code:

From:

new YT.Player(players[i], {
    playerVars: {
        'autoplay': 1,
        'modestbranding': 1,
        'controls': 1,
        events: {
        'onReady': onPlayerReady
        }
    },
    videoId: players[i].dataset.id
});

To

new YT.Player(players[i], {
    playerVars: {
        'autoplay': 1,
        'modestbranding': 1,
        'controls': 1},
        events: {
        'onReady': onPlayerReady
    },
    videoId: players[i].dataset.id
});

Base on the sample code given by google. Events element is outside the playerVars element. Here is the link for the supported list of parameters int playerVars element.

function onYouTubeIframeAPIReady() {
    var player;
    player = new YT.Player('player', {
        videoId: 'M7lc1UVf-VE',
        playerVars: { 'autoplay': 1, 'controls': 0 },
        events: {
            'onReady': onPlayerReady,
            'onPlaybackQualityChange': onPlayerPlaybackQualityChange,
            'onStateChange': onPlayerStateChange,
            'onError': onPlayerError
        }
    });
}

See this jsfiddle as example.


Post a Comment for "Autoplay Multiple YouTube Videos On Mute At Once"