I'm trying to make a player, that gets a url from a tableview (not done yet). I started trying to make the player work, with MPMediaPlayerController.
NSString *video = [NSString stringWithFormat:@"http://www.youtube.com/watch?v=GurkREc-q4I"];
NSURL *url = [NSURL URLWithString:video];
MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc]initWithContentURL:url];
[moviePlayerController.view setFrame:[self.view frame]];
[self.view addSubview:moviePlayerController];
[moviePlayerController setShouldAutoplay:YES];
[moviePlayerController prepareToPlay];
moviePlayerController.fullscreen = YES;
[moviePlayerController play];
When I try to add the moviePLayer as a subview I get this warning: Incompatible pointer types sending 'MPMoviePlayerController *' to parameter of type 'UIView *'.
Also, when I open the view, the app closes, and in console we have this:
2014-03-04 18:26:50.696 FavVideos[6181:70b] -[MPMoviePlayerController superview]: unrecognized selector sent to instance 0xa63c470 2014-03-04 18:26:50.735 FavVideos[6181:70b] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MPMoviePlayerController superview]: unrecognized selector sent to instance 0xa63c470'
Any ideas about what I'm doing wrong?
Thanks since now.
Edit:
Ok, I saw what I was doing to get the error and the "crash".
Here:
[self.view addSubview:moviePlayerController];
I changed to:
[self.view addSubview:moviePlayerController.view];
No more warnings or crashes. But the player is just a black screen, any ideas?