0

这是我的实现文件:

-(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>
)

它加载播放器视图并直接关闭子播放器视图。

有什么建议么?

4

1 回答 1

0

阅读错误。在您的代码(或苹果代码)的某处,有一个 KVO Observer 未被删除。我不认为你可以设置playercontroller为 nil 并期望它保留自己。尝试坚持对它的引用并成为它的代表。

于 2012-08-03T00:01:25.770 回答