2

有人知道为什么这段代码会在发布池中的某个地方崩溃(在调用“弹出”之后)吗?我在 AVPlayer 类参考中看到“currentItem”属性未声明为“保留” http://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVPlayer_Class/Reference/Reference.html#//apple_ref /doc/uid/TP40009530-CH1-SW21

它是 AVPlayer 类中的错误还是我应该将其保留在其他地方?

谢谢!

- (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];
}
4

2 回答 2

2

我通常使用它来设置播放器:

if (!self.player) {
    player = [[AVPlayer alloc] init];
    }

    [self.player replaceCurrentItemWithPlayerItem:[AVPlayerItem playerItemWithURL:videoURL]];
于 2011-01-19T19:16:35.943 回答
0

我相信 AVPlayer 在 initWithPlayerItem: 函数中保留了 AVPlayerItem,因此您的 AVPlayerItem 可能会泄漏内存。“currentItem”是只读属性,不应该是仅用于可写属性的“保留”。

于 2012-04-09T09:18:15.010 回答