AVPlayerItem“资产” iOS 4.2 中属性始终为 nil
根据 Apple 文档,在 iOS 4.0 及以上版本中,AVPlayerItem 的“asset”属性应该可用并返回有效的对象。我发现在 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];
}
}
还有其他人看过这个吗?
According to the Apple documentation, the 'asset' property of an AVPlayerItem should be available and return a valid object in iOS 4.0 onward. I have found that in iOS 4.2 that the 'asset' property of an AVPlayerItem object is always nil. Example code:
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];
}
}
Has anyone else seen this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我可以确认,就我而言,在 4.2.1 iPad 上,该属性确实具有价值。在此屏幕截图中,我的调试器位于有问题的线路上。
I can confirm that in my case, on a 4.2.1 iPad, that this property does in fact hold a value. In this screenshot my debugger is sitting on the line in question.