【发布时间】:2012-08-24 13:31:51
【问题描述】:
我正在使用 GDataFeedYouTubeVideo 用图像和标题填充表格视图。这行得通。我想在选择单元格后播放视频。我正在使用提要中的 url 传递给 MPMoviePlayer,它看起来像加载,因为屏幕变黑,调用了 moviePlaybackDidFinish 但不播放视频并返回显示 tableview?来自提要的示例网址是:
https://www.youtube.com/v/o7QAMH3qRvU?version=3&f=user_uploads&app=youtube_gdata
这在浏览器中有效,但在 MPMoviePlayer 中无效?请帮我解决这个问题。我宁愿不必编写一些 hack 例程来替换或删除提要返回的 URLString。我正在使用 ARC 和故事板。我第二次选择一个单元格时:
类 AVPlayerItem 的实例 0xce6a7b0 已被释放,而键值观察者仍向其注册...
是的,我确实尝试了以下建议: iOS 5 an instance of AVPlayerItem was deallocated 这并没有解决它。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
YouTubeVideo *item = [searchList objectAtIndex:indexPath.row];
if (item != nil) {
NSURL *url = [NSURL URLWithString:item.URLString];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlaybackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
moviePlayer.controlStyle = MPMovieControlStyleDefault;
moviePlayer.shouldAutoplay = YES;
[self.view addSubview:moviePlayer.view];
[moviePlayer 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];
}
【问题讨论】:
标签: xcode mpmovieplayer