2012-04-10 120 views
2

想知道是否有可能(以及如何)使用YouTube iframe API在播放器外部具有html按鈕或鏈接來打開和關閉聲音。YouTube API音量開關

感謝,
莫羅

+0

參見[這](http://www.tikku.com/jquery-youtube-tubeplayer-plugin#tubeplayer_tutorial_1) – CosminO 2012-04-10 13:51:25

回答

-1

看到jQuery Youtube Plugin完整規格和下載。
將有可能宣佈一個球員像這樣:

jQuery("#youtube-player-container").tubeplayer({ 
     width: 600, // the width of the player 
     height: 450, // the height of the player 
     allowFullScreen: "true", // true by default, allow user to go full screen 
     initialVideo: "DkoeNLuMbcI", // the video that is loaded into the player 
     preferredQuality: "default",// preferred quality: default, small, medium, large, hd720 
     onPlay: function(id){}, // after the play method is called 
     onPause: function(){}, // after the pause method is called 
     onStop: function(){}, // after the player is stopped 
     onSeek: function(time){}, // after the video has been seeked to a defined point 
     onMute: function(){}, // after the player is muted 
     onUnMute: function(){} // after the player is unmuted 
    }); 
Then just add a link with the desired function: 
<a href="#" onClick='jQuery("#youtube-player-container").tubeplayer("mute")'> 
Mute player 

+0

有無需使用任何外部插件,因爲youtube api已經爲您提供'player.mute()'和'player.unMute()'來切換聲音並且'player.isMuted()'檢查聲道的狀態。這個解決方案是過度編碼,當你可以使用一個簡單的JavaScript點擊事件... – easwee 2014-07-09 09:44:33