0

i m parsing a json feed containg you tube feeds where i m trying the play the youtube in a fixed frame .when i click the button i getting black background could u guys help me out below is the code

-(void)watchClip:(id)sender
{
NSLog(@"hello how should this be:%@",URL);
 NSURL *fileURL=[NSURL URLWithString:[URL   stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];   
MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];  
moviePlayerController.view.frame=CGRectMake(28,15,250,130);  
[[NSNotificationCenter defaultCenter] addObserver:self  
                                         selector:@selector(moviePlaybackComplete:)  
                                             name:MPMoviePlayerPlaybackDidFinishNotification  
                                           object:moviePlayerController];  
   //moviePlayerController.fullscreen = YES;  

  [v addSubview:moviePlayerController.view];

[moviePlayerController play];  

 }
user578386
  • 1,061
  • 3
  • 14
  • 37

1 Answers1

1

MPMoviePlayerController can't play YouTube videos. Use a UIWebView instead.

Play YouTube videos with MPMoviePlayerController instead of UIWebView

Here's a good tutorial on how to play youtube videos in a fixed frame. Note that if you're running in the simulator it won't work.

Community
  • 1
  • 1
Dustin
  • 6,783
  • 4
  • 36
  • 53
  • This was true as of iOS 5. It may or may not be true now; feel free to try it and report back so that this question may be appropriately answered. – Dustin Sep 30 '13 at 20:29