Javascript YouTube API在Safari中不静音(非iOS)

Javascript YouTube API在Safari中不静音(非iOS),javascript,iframe,youtube,youtube-api,Javascript,Iframe,Youtube,Youtube Api,我已经用下面的代码初始化了我的播放器。它在Chrome、FireFox和IE中的静音效果很好,但在Safari中没有。朋友,有什么想法吗 function onYouTubeIframeAPIReady() { player = new YT.Player('iframe-wrapper', { height: videoHeight, width: videoWidth, videoId: id, events: {

我已经用下面的代码初始化了我的播放器。它在Chrome、FireFox和IE中的静音效果很好,但在Safari中没有。朋友,有什么想法吗

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();
}

只需在
onPlayerReady()中添加一些代码即可:

也可以为静音创建单独的功能:

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

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

按照和中的指导代码进行操作。

问题在于onPlayerReady事件没有触发。显然,这是一个已知的问题,在YouTube API中没有很好的记录

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

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