【发布时间】:2014-04-04 09:24:45
【问题描述】:
我需要澄清在 ios 中导入的 youtube 视频网址。我的场景是,我创建了一个 tableview,当我单击单元格时,它将导航到我的 Detailviewcontroller。在 detailviewcontroller 页面中,我有一个 UIButton,当我单击该按钮时,它将播放视频。此视频网址包含 youtube 视频网址。它在 3 天前工作正常。现在它不起作用。我不知道我的代码有什么错误。
我的代码是: DetailViewController.m
-(IBAction)YouTube:(id)sender
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
PlayViewController *PVC = [storyboard instantiateViewControllerWithIdentifier:@"PlayViewController"];
PVC.videourl=strVideoURL;
[self.navigationController pushViewController:PVC animated:YES];
}
PlayViewController.m
-(void)viewDidLoad
{
NSArray *arr=[YoutubeParser parseHTML:videourl];
NSString *myArrayString = [arr objectAtIndex:0];
videoPlayerViewController = [[XCDYouTubeVideoPlayerViewController alloc] initWithVideoIdentifier:myArrayString];
[self presentMoviePlayerViewControllerAnimated:videoPlayerViewController];
NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
[defaultCenter addObserver:self selector:@selector(moviePlayerPlaybackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
[defaultCenter addObserver:self selector:@selector(moviePlayerPlaybackStateDidChange:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:nil];
[defaultCenter addObserver:self selector:@selector(moviePlayerLoadStateDidChange:) name:MPMoviePlayerLoadStateDidChangeNotification object:nil];
}
【问题讨论】:
-
使用 UIWebView 播放 youtube 视频,你就不会遇到这些问题
标签: ios objective-c youtube xcode5