views:

54

answers:

1

I have a MPMoviePlayerController, and I can successfully play a (local) video with it.

The duration property is not being set to the runlength of the video - even after I receive a MPMovieDurationAvailableNotification event, the value remains set to 0.

Has anyone seen this before?

A: 

I had this problem and I eventually worked out that I wasn't properly casting the value for output. Instead of:

self.durationLabel.text = [NSString stringWithFormat:"Duration: %d",self.player.duration]

I needed something more like:

self.durationLabel.text = [NSString stringWithFormat:"Duration: %f",(float) self.player.duration]

And ultimately output:

self.durationLabel.text = [NSString stringWithFormat:@"Running Time: %d min",(int) ceil(self.player.duration/60)];

Fireandlight27