Reputation: 31
here i want to play a youtube video using mediaplayer framework.For this i follow this process, 1)I am adding mediaplayer framework. 2)I am importing #import header file 3)I implemented code by using google
But it shows thread ,
Can any one tell me how to solve this problem.
Upvotes: 3
Views: 6461
Reputation: 1918
Please check this out:
http://mobile.tutsplus.com/tutorials/iphone/iphone-sdk-playing-video-with-the-mediaplayer-framework/ as well check this thread : how to play video from url using mpplayer?
Upvotes: 1
Reputation: 17535
Please try thie one .. i think this one may your help.
- (IBAction)playVideo:(id)sender
{
NSURL *videosURL = [NSURL URLWithString:@"YourVideoURL"];
MPMoviePlayerController *moviePlayController = [[MPMoviePlayerController alloc]initWithContentURL:videosURL];
[self.view addSubview:moviePlayController.view];
[moviePlayController prepareToPlay];
moviePlayController.controlStyle = MPMovieControlStyleDefault;
moviePlayController.shouldAutoplay = YES;
[moviePlayController setFullscreen:YES animated:YES];
}
- (void) moviePlayBackDidFinish:(NSNotification*)notification
{
MPMoviePlayerController *player = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification object:player];
if ([player respondsToSelector:@selector(setFullscreen:animated:)])
{
[player.view removeFromSuperview];
}
}
Upvotes: 1