这是我的代码
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];
所以视频应该在我启动应用程序时播放,但它没有播放。任何人都可以看到代码中的错误吗?我包含了MediaPlayer框架并导入了Mediaplayer.h 谢谢!
答案 0 :(得分:1)
您无法通过MPMoviePlayerController播放YouTube视频。使用UIWebView或默认应用程序和自定义URL方案实现此目标
另见 Play YouTube videos with MPMoviePlayerController instead of UIWebView