'NSInvalidArgumentException', reason: '-[AVPlayerItem duration]: unrecognized selector sent

纵饮孤独 提交于 2019-12-25 02:26:02

问题


I am trying to play a MediaItem using AVPlayer and later trying to get the duration of the current item like this (duration is an object of type CMTime):

duration = [[player currentItem] duration];

I get no issues in iPad but in iPod Touch, I get the following error. I haven't tried this in iPhone yet.

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AVPlayerItem duration]: unrecognized selector sent to instance 0x186100'

Any pointers to the fix will be greatly appreciated.


回答1:


You're most likely testing this on an iPod with iOS < 4.3.

According to the AVPlayerItem documentation, duration is only available in iOS 4.3 or later.



来源:https://stackoverflow.com/questions/9287308/nsinvalidargumentexception-reason-avplayeritem-duration-unrecognized-se

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!