Reputation: 644
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];
Its works fine but it play automatically. but after finish play the video it shows play button to play again. I need that play button in webview like in youtube in first time itself. While I click that button then only I need to play the video. please Suggest me any idea...
Upvotes: 1
Views: 2011
Reputation: 3660
How about setting
videoView.mediaPlaybackRequiresUserAction = NO;
to YES instead?
Upvotes: 0
Reputation: 800
Go threw this url and just replace your "NSString* embedHTML" value. its working fine.
Embed youtube video in iOS App
Upvotes: 0
Reputation: 644
I found my ans in embedHTML there is option a.target.playVideo();
I changed that into a.target.pauseVideo();
it works fine....
Upvotes: 2