在这里,我想使用Mediaplayer框架播放youtube视频。为此,我按照以下流程进行操作,
1)我正在添加mediaplayer框架。
2)我正在导入#import头文件
3)我通过使用谷歌实现代码
但是它显示线程,
谁能告诉我如何解决这个问题。
最佳答案
请尝试这个..我认为这可能对您有所帮助。
- (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];
}
}