1

Possible Duplicate:
Play YouTube videos with MPMoviePlayerController instead of UIWebView

I am trying to play video from a youtube url and once mpmovieplayer is launched, it is been closed instantly. How to play video from youtube url? note that I am using iOS5. Thanks.

- (IBAction)video1 {

        //NSBundle *bundle = [NSBundle mainBundle];
        //NSString *moviePath =[bundle pathForResource:@"" ofType:@"mp4"];
        NSURL *movieURL = [NSURL fileURLWithPath:@"http://www.youtube.com/testVideo"];
        MPMoviePlayerController *daMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
        daMovie.scalingMode = MPMovieScalingModeAspectFill;
        [daMovie play];
        MPMoviePlayerViewController *moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:movieURL];
        [self presentMoviePlayerViewControllerAnimated:moviePlayer];

    }
Community
  • 1
  • 1
Jaume
  • 913
  • 2
  • 17
  • 31

1 Answers1

1

YouTube recommends you use the native YouTube-app, see this link for more info on that: http://apiblog.youtube.com/2009/02/youtube-apis-iphone-cool-mobile-apps.html

Otherwise, check out this question on StackOverflow: Play YouTube videos with MPMoviePlayerController instead of UIWebView

Community
  • 1
  • 1
Emil
  • 7,220
  • 17
  • 76
  • 135