2016-04-07 17 views
0

我已經用下面的代碼初始化了我的播放器。它在Chrome,FireFox和IE中靜音,但不是Safari。任何想法amigos?YouTube API無法在Safari中靜音(不是iOS)

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

回答

0

問題最終導致onPlayerReady事件沒有被觸發。顯然這是一個已知的問題,在YouTube API中沒有很好的記錄。 Here's a link to the answer

0

只需添加一些代碼在你onPlayerReady()

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

,或者您可以靜音創建一個單獨的功能:

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

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

按照該指南代碼youtube api documentjsfiddle sample

相關問題