ideoView = [[UIWebView alloc] initWithFrame:CGRectMake(60, 20, 200, 184)];
videoView.delegate = self;
videoView.scrollView.bounces = NO;
videoView.allowsInlineMediaPlayback = YES;
videoView.mediaPlaybackAllowsAirPlay = YES;
videoView.mediaPlaybackRequiresUserAction = NO;
[self.view addSubview:videoView];
NSString* embedHTML = [NSString stringWithFormat:
@"<html><body style='margin:0px;padding:0px;'><script type='text/javascript'src='http://www.youtube.com/iframe_api'></script><script type='text/javascript'>function onYouTubeIframeAPIReady(){ytplayer=new YT.Player('playerId',{events:{onReady:onPlayerReady}})}function onPlayerReady(a){ a.target.playVideo(); }</script><iframe id='playerId' type='text/html' width='%@' height='%@'src='http://www.youtube.com/embed/%@?enablejsapi=1&rel=0&playsinline=1&controls=1&showinfo=1' frameborder='0'></body></html>", [NSString stringWithFormat:@"%d", 200], [NSString stringWithFormat:@"%d", 184], url];
[videoView loadHTMLString:embedHTML baseURL:nil];
它工作正常,但它会自动播放。但播放完视频后,它会显示播放按钮以再次播放。我第一次需要在 webview 中播放按钮,就像在 youtube 中一样。当我点击那个按钮时,我只需要播放视频。请给我任何想法...
最佳答案
我在 embedHTML 中找到了我的答案 a.target.playVideo();
我把它改成了 a.target.pauseVideo();
它工作正常....
关于ios - 我不想在 UIWebview 中自动播放 play youtube video,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20344439/