我正在使用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