需要 MPMoviePlayerController 初始化方面的帮助
我有一个应用程序,允许用户使用向下钻取表视图模型从媒体项目列表移动到特定项目。
用户进入详细信息视图后,另一个表格视图存在允许用户选择特定媒体项目。
我在创建要播放的模态媒体播放器时遇到问题.mp4 项目。下面的代码是我到目前为止所拥有的。
if (indexPath.section == SectionHeader && indexPath.row == SectionHeaderEnclosure) {
if (item.enclosures) {
for (NSDictionary *dict in item.enclosures){
NSString *url = [dict objectForKey:@"url"];
NSLog(@" url is : %@",url);
//EXPERIMENTAL
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
// Register to receive a notification when the movie has finished playing.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];
if ([moviePlayer respondsToSelector:@selector(setFullscreen:animated:)]) {
// Use the 3.2 style API
moviePlayer.controlStyle = MPMovieControlStyleDefault;
moviePlayer.shouldAutoplay = YES;
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:YES];
} else {
// Use the 2.0 style API
moviePlayer.movieControlMode = MPMovieControlModeHidden;
[moviePlayer play];
}
}
}
}
我需要这行的帮助: MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
它给了我一个 NSInvaild Argument Exception 。我需要有关创建视频播放器以及随后从视图中删除的帮助。
I have an app that allows the user to move from a list of media items to a specific item using the drill-down table view model.
Once the user is inside the detail view, another table view exists allowing the user to select a specific media item.
I am having an issue creating a modal media player to play the .mp4 items. The code below is what I have so far.
if (indexPath.section == SectionHeader && indexPath.row == SectionHeaderEnclosure) {
if (item.enclosures) {
for (NSDictionary *dict in item.enclosures){
NSString *url = [dict objectForKey:@"url"];
NSLog(@" url is : %@",url);
//EXPERIMENTAL
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
// Register to receive a notification when the movie has finished playing.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];
if ([moviePlayer respondsToSelector:@selector(setFullscreen:animated:)]) {
// Use the 3.2 style API
moviePlayer.controlStyle = MPMovieControlStyleDefault;
moviePlayer.shouldAutoplay = YES;
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:YES];
} else {
// Use the 2.0 style API
moviePlayer.movieControlMode = MPMovieControlModeHidden;
[moviePlayer play];
}
}
}
}
I need help with this line:
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
It is giving me an NSInvaild Argument Exception. I need help with the video player creation and subsequent deletion from the view.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来您已将 URL 存储为纯
NSString
,而播放器需要一个NSURL
。这个怎么样?It looks like you have the URL stored as a plain
NSString
, whereas the player expects anNSURL
. How about this?