0

I have initialized my player with the code below. It mutes fine in Chrome, FireFox, and IE, but not Safari. Any thoughts amigos?

function onYouTubeIframeAPIReady() {
    player = new YT.Player('iframe-wrapper', {
        height: videoHeight,
        width: videoWidth,
        videoId: id,
        events: {
            'onReady': onPlayerReady
        },
        playerVars: {
            'autoplay': 1,
            'controls': 0,
            'autohide': 1,
            'wmode': 'opaque',
            'showinfo': 0,
            'loop': 1,
            'mute': 1
        }
    });
}
  function onPlayerReady() {
    player.mute();
    player.playVideo();
}
Reed Martin
  • 159
  • 1
  • 3
  • 11

2 Answers2

0

Just add some code in your onPlayerReady():

function onPlayerReady(event) {
event.target.mute();
}

or you can create a separate function for mute:

function onMute() {
player.mute();
}

function onUnMute() {
player.unMute();
}

Follow the guide code in youtube api document and jsfiddle sample.

Mr.Rebot
  • 6,703
  • 2
  • 16
  • 91
0

The problem ended up being that the onPlayerReady event wasn't firing. Apparently this is somewhat of a known issue and isn't terribly well documented in the YouTube API. Here's a link to the answer.

Community
  • 1
  • 1
Reed Martin
  • 159
  • 1
  • 3
  • 11