我正在尝试使用MPMoviePlayerController从我的iOS应用中的URL播放YouTube视频,但我只是得到一个黑屏并且没有播放。我究竟做错了什么?我已经验证了网址是否正确并且正在传递正确的videoId。
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
NSString *urlString = [NSString stringWithFormat:@"https://www.youtube.com/watch?v=%@", videoIDString];
NSURL *videoURL = [NSURL URLWithString:urlString];
MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
moviePlayerController.scalingMode = MPMovieScalingModeAspectFit;
moviePlayerController.shouldAutoplay = YES;
moviePlayerController.fullscreen = YES;
[moviePlayerController.view setFrame:CGRectMake(0, 70, 320, 270)];
[self.view addSubview:moviePlayerController.view];
[moviePlayerController play];
}