YouTube API音量开关

问题描述:

想知道是否有可能(以及如何)使用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

看到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