在iOS 4.2中,AVPlayerItem'asset'属性始终为零

时间:2011-09-04 01:19:53

标签: avplayer

根据Apple文档,AVPlayerItem的'asset'属性应该可用,并在iOS 4.0以后返回有效对象。我发现在iOS 4.2中,AVPlayerItem对象的'asset'属性始终为nil。示例代码:

CMTime theDuration = kCMTimeInvalid;
AVPlayerItem* theItem = anAVPlayer.currentItem;
AVAsset* theAsset = nil;

if ([AVPlayerItem instancesRespondToSelector:@selector(duration)]) {
    // On iOS 4.3 we get here...
    theDuration = [theItem duration];
} else if ([AVPlayerItem instancesRespondToSelector:@selector(asset)]) {
    // On iOS 4.2 we get here...
    theAsset = [theItem asset];

    if (theAsset) {
        // Unfortunately, we do not get here as theAsset is nil...
        theDuration = [theAsset duration];
    }
}

有没有人见过这个?

1 个答案:

答案 0 :(得分:0)

我可以确认,在我的情况下,在4.2.1 iPad上,这个属性确实持有一个值。在此屏幕截图中,我的调试器位于相关行中。

enter image description here