问题
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