Bijoy Thangaraj
Bijoy Thangaraj

Reputation: 5546

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

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.

Upvotes: 0

Views: 1029

Answers (1)

edc1591
edc1591

Reputation: 10182

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.

Upvotes: 4

Related Questions