这是我的实施文件:
-(IBAction)playvideo {
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"Intro" ofType:@"mp4"]];
MPMoviePlayerViewController *playercontroller = [[MPMoviePlayerViewController alloc]
initWithContentURL:url];
[self presentMoviePlayerViewControllerAnimated:playercontroller];
playercontroller.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
[playercontroller.moviePlayer play];
playercontroller = nil;
}
这是一个奇怪的错误:
2012-08-03 01:48:40.085 Assaultive[5569:16a03] An instance 0x9b5ad50 of class AVPlayerItem was deallocated while key value observers were still registered with it. Observation info was leaked, and may even become mistakenly attached to some other object. Set a breakpoint on NSKVODeallocateBreak to stop here in the debugger. Here's the current observation info:
<NSKeyValueObservationInfo 0x8549f10> (
<NSKeyValueObservance 0x9b5cde0: Observer: 0x9b58690, Key path: nonForcedSubtitleDisplayEnabled, Options: <New: YES, Old: NO, Prior: NO> Context: 0x0, Property: 0x9b5ce60>
<NSKeyValueObservance 0x9b5cfa0: Observer: 0x9b54b90, Key path: presentationSize, Options: <New: NO, Old: NO, Prior: NO> Context: 0x0, Property: 0x9957780>
)
加载玩家视图,直接关闭子玩家视图。
有什么建议吗?
答案 0 :(得分:0)
阅读错误。在您的代码(或苹果)的某处,有一个KVO Observer没有被删除。我不认为你可以将playercontroller
设置为nil并期望它保留自己。试着坚持对它的引用并成为它的代表。