有人知道为什么这段代码会在发布池中的某个地方崩溃(在调用'eject‘之后)吗?我在AVPlayer类引用中看到,'currentItem‘属性没有声明为'retain’http://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVPlayer_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40009530-CH1-SW21
它是AVPlayer类中的一个bug,还是应该将它保留在其他地方?
谢谢!
- (void) viewDidLoad {
NSURL *url = [NSURL URLWithString:@"http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"];
playerItem = [[AVPlayerItem alloc] initWithURL:url];
player = [[AVPlayer alloc] initWithPlayerItem:playerItem];
}
- (IBAction) eject {
[player release];
[playerItem release];
}发布于 2011-01-20 03:16:36
我通常使用下面的代码来设置播放器:
if (!self.player) {
player = [[AVPlayer alloc] init];
}
[self.player replaceCurrentItemWithPlayerItem:[AVPlayerItem playerItemWithURL:videoURL]];发布于 2012-04-09 17:18:15
我相信AVPlayer在initWithPlayerItem: function中保留了AVPlayerItem,所以您的AVPlayerItem可能会泄漏内存。"currentItem“是只读属性,不应该是"retain”,因为它只适用于可写属性。
https://stackoverflow.com/questions/4375919
复制相似问题