1
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...

Seeker
  • 644
  • 1
  • 8
  • 18
  • Hi now I solve my prob from below code... Now I need controls in webview. Now currently I got controls but it wont show the playback slider. It shows playBack slider only in full screen... now i need to show slider even webview in normal size – Seeker Dec 03 '13 at 07:08
  • why don't you use the `iframe` only, that will stream the video.. – NULL Dec 03 '13 at 07:24
  • @Aminul: please tell properly what you are telling.. I solved my issue and post my ans.. Now what i need mentioned above of ur comment – Seeker Dec 03 '13 at 07:27

3 Answers3

2

I found my ans in embedHTML there is option a.target.playVideo(); I changed that into a.target.pauseVideo(); it works fine....

Seeker
  • 644
  • 1
  • 8
  • 18
0

Go threw this url and just replace your "NSString* embedHTML" value. its working fine.

Embed youtube video in iOS App

Community
  • 1
  • 1
Naveen kumar
  • 800
  • 1
  • 5
  • 23
  • hi already found my ans and posted it.. Now the webview shows playback slider only when the webview width is 320.. other wise it neglect the slider control show other controls.. What to do now – Seeker Dec 03 '13 at 07:25
  • try this code webView.scrollView setShowsVerticalScrollIndicator:NO]; webView.scrollView.contentSize = CGSizeMake(webView.frame.size.width, webView.frame.size.height); – Naveen kumar Dec 03 '13 at 07:29
0

How about setting

videoView.mediaPlaybackRequiresUserAction = NO;

to YES instead?

Saren Inden
  • 3,450
  • 4
  • 32
  • 45