开发者

AVPlayer does not retain AVPlayerItem

Does somebody know why this code is crashing somewhere in the release pool (after 'eject' is called)? I saw in AVPlayer class reference that the 'currentItem' property is NOT declared as 'retain' http://develo开发者_如何转开发per.apple.com/library/ios/documentation/AVFoundation/Reference/AVPlayer_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40009530-CH1-SW21

Is it a bug in the AVPlayer class or should I retain it somewhere else?

Thanks!

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


I typically use this to setup a player:

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

    [self.player replaceCurrentItemWithPlayerItem:[AVPlayerItem playerItemWithURL:videoURL]];


I believe that AVPlayer retains AVPlayerItem in initWithPlayerItem: function, so you are possibly leaking memory with your AVPlayerItem. "currentItem" is readonly property and should not be "retain" which is only for writable properties.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜