我正在使用UIWebView播放嵌入的YouTube视频,在iOS 9上为iPhone。如何播放UIWebView中的YouTube视频静音?
然而,由于的已知问题,音量控制不工作,即调用player.mute()或player.setVolume(0)不会在所有的工作: https://github.com/youtube/youtube-ios-player-helper/issues/20
我想知道是否有人成功解决了这个问题?你能分享一下你的方法吗?
我使用的样品嵌入HTML:
<html><body style='margin:0px;padding:0px;'>
<script type='text/javascript' src='http://www.youtube.com/iframe_api'></script><script type='text/javascript'>
var player;
function onYouTubeIframeAPIReady()
{player=new YT.Player('playerId',{events:{onReady:onPlayerReady}})}
function onPlayerReady(event){player.mute();player.setVolume(0);player.playVideo();}
</script>
<iframe id='playerId' type='text/html' width='1280' height='720'
src='https://www.youtube.com/embed/R52bof3tvZs?enablejsapi=1&rel=0&playsinline=1&autoplay=1&showinfo=0&autohide=1&controls=0&modestbranding=1' frameborder='0'>
</body></html>
谢谢!
解决办法可能是监听WebView的私人通知,并从通知对象获取播放器对象,然后将其静音。 –
@MuhammadZeeshan你有什么例子吗? – RainCast