0

Here is my code

NSURL *url = [NSURL URLWithString:@"http://www.youtube.com/watch?v=2mcjR3TsK4s&feature=g-logo&context=G2e376ceFOAAAAAAAAAA"];
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:url];
[self.view addSubview:mp.view];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMovieFinished:) name:MPMoviePlayerPlaybackDidFinishNotification object:mp];
[mp play]; 

So video shoul play when I starts the app but it is not playing. Can anybody see what is wrong in code? I included MediaPlayer framework and import Mediaplayer.h Thanks!

Richard J. Ross III
  • 53,315
  • 24
  • 127
  • 192
Dmitriy Kalachniuk
  • 372
  • 1
  • 6
  • 24

1 Answers1

1

You cannot play YouTube video via MPMoviePlayerController. Use UIWebView or default app with custom URL scheme for this aim

See also Play YouTube videos with MPMoviePlayerController instead of UIWebView

Community
  • 1
  • 1
beryllium
  • 29,214
  • 15
  • 99
  • 123