iPhone App :How to play Youtube video in app using MPMoviePlayerController

11,749

There is a great thread that on IphoneDevSDk.

They work with a hidden UIWebView: http://www.iphonedevsdk.com/forum/iphone-sdk-development/61447-how-play-youtube-movie.html

Share:
11,749
ios
Author by

ios

Updated on June 04, 2022

Comments

  • ios
    ios almost 2 years

    iPhone App :How to play Youtube video in app using MPMoviePlayerController

    for that i write the code:

     NSString *urlAddress = @"http://www.youtube.com/xyz";
     NSLog(@"URL ADDress : %@",urlAddress);
    
     //Create a URL object.
      NSURL *url = [NSURL URLWithString:urlAddress];
    
    movie = [[MPMoviePlayerController alloc] initWithContentURL:url];
    movie.scalingMode=MPMovieScalingModeAspectFill;
        movie.view.frame = CGRectMake(0.0, 0.0, 320.0, 460.0);
    [self.view addSubview:movie.view];
    [movie play];
    

    if i pass the url of local directory it is playing video

     NSString* filePath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"Video.mp4"];
    NSURL* url = [[[NSURL alloc] initFileURLWithPath:filePath] autorelease];
    

    How can I play video directly from youtube url to MPMoviePlayerController?

  • Narayanan Ramamoorthy
    Narayanan Ramamoorthy almost 13 years
    @rckoenes why not ?? i have played youtube by downloading it and saved in local ...another mean of playing is embedding the youtube link and playing in safari
  • steipete
    steipete about 12 years
    I tried this here: github.com/steipete/PSYouTubeExtractor, but it's a very flaky solution and doesn't work well with iOS5. Google clearly doesn't like it. If only the UIWebView plugin wouldn't be SO shitty.