Take the 2-minute tour ×

I am developing an app for the iPhone, in which I am running a Youtube video on UIwebView. In that, I want to retrieve all the information about the video (when the video started and how much time it took to complete the video). I am trying to get this information every 2 seconds.

I have not been able to get such notificatons. I have also tried doing that with JavaScript, but I read somewhere that it requires Flash Player and the iPhone doesn't support it. So JavaScript is not an option.

Can anyone suggest me how can I move forward from here? Thanks.

My code:

//  YouTubeEmbedViewController.m
//  YouTubeEmbed
//  Created by Movik Networks on 11/04/12.
//  Copyright 2012 __MyCompanyName__. All rights reserved.

#import "YouTubeEmbedViewController.h"

@implementation YouTubeEmbedViewController
@synthesize thumbnailView;

- (void)didReceiveMemoryWarning
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];


#pragma mark - View lifecycle

- (void)viewDidLoad
    [super viewDidLoad];
    // webView is a UIWebView, either initialized programmatically or loaded as part of a xib.

    NSString *htmlString = @"<html><head><meta name = \"viewport\" content = \"initial-scale = 1.0, user-scalable = no, width = 300\"/></head><body style=\"background:#F00;margin-top:0px;margin-left:0px\"><div><object width=\"300\" height=\"300\"><param name=\"movie\" value=\"http://www.youtube.com/watch?v=oSOooSv1RH0\"></param><param name=\"wmode\" value=\"transparent\"></param><embed src=\"http://www.youtube.com/watch?v=oSOooSv1RH0\"type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"300\" height=\"300\"></embed></object></div></body></html>";

    [thumbnailView loadHTMLString:htmlString baseURL:[NSURL URLWithString:@"http://www.google.com"]];


- (void)viewDidUnload
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);

share|improve this question

1 Answer 1

You may use the Youtube API with the client library

then you can play the files in MPMoviePlayerViewController and use it's delegate functions.

share|improve this answer
Thanks for the suggestion. I will Try this out and will inform you. Thanks a lot Max. –  Akansha Apr 10 '12 at 5:06
Hello Max, I tried a lot throught the way you suggested. I tried by first dwonloading the libraries, and to run the examples given in the gdata libraries. HERE IS THE EXAMPLE I am using xcode 4.0 and when I tried to make a build to execute it, it gives out some error like "GDataHTTPFetcher may not respoond to '-connection:didFailWithError'" I tried a lot but still same error remains. –  Akansha Apr 10 '12 at 10:08
There used to be an issue with iOS 5: code.google.com/p/gdata-objectivec-client/issues/detail?id=97 Do you develop for ios5? Why do u use Xcode 4.0? –  Max Ballo Apr 10 '12 at 14:46
My requirement is to make this app work in least possible version of iOS. So i am using xcode 4.0 so that is can support iOS 4 as well !! –  Akansha Apr 11 '12 at 7:57
I tried by embeding the youtube in the Uiwebview, but still I am not getting any events. Here is my code that I am using. Where and what should I add to get some events back? PLease find the edited question for the code. –  Akansha Apr 11 '12 at 8:05

Your Answer


