我的应用程序包含一个带有自定义 UIButtons 的视频来管理视频。通过使用 Youtube iFrame api,我设法在 UIWebView 中播放 youtube 视频并隐藏其所有默认控件(用于全屏、音量等)。现在我想通过自定义按钮控制视频。我怎么做?- 全屏 UIButton:使视频全屏 - 静音/取消静音按钮:静音/取消静音视频
从我的另一个问题中引用屏幕:
我该如何解决这个问题?UIWebview 中的视频代码:
NSString *htmlString =@"<!DOCTYPE html><html> <body><div id=\"player\"></div><script>var tag = document.createElement('script');tag.src = \"https://www.youtube.com/iframe_api\";var firstScriptTag = document.getElementsByTagName('script')[0];firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);var player;function onYouTubeIframeAPIReady() {player = new YT.Player('player', {height: '196',width: '309',videoId: 'GOiIxqcbzyM',playerVars: {playsinline: 1, controls: 0}, events: {'onReady': onPlayerReady,'onStateChange': onPlayerStateChange}});}function onPlayerReady(event) {event.target.playVideo();}var done = false;function onPlayerStateChange(event) {if (event.data == YT.PlayerState.PLAYING && !done) {setTimeout(stopVideo, 6000);done = true;}}function stopVideo() {}</script></body></html>";
_webViewVideo.delegate = self;
static NSString *youTubeVideoHTML = @"<iframe webkit-playsinline width=\"309\" height=\"200\" src=\"https://www.youtube.com/embed/GOiIxqcbzyM?feature=player_detailpage&playsinline=1\" frameborder=\"0\"></iframe>";
[_webViewVideo loadHTMLString:htmlString baseURL:[[NSBundle mainBundle] resourceURL]];