I have no problem playing the video, just cant seem to get my label to update with the video's duration. (entire video length).
The following method works fine using AVAudioPlayer
:
- (void) updateDurationLabel {
NSURL *url = /* not an issue */
MPMoviePlayerViewController *video = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
int duration = video.moviePlayer.playableDuration; /* not the same as AVAudioPlayer */
int minutesDur = duration / 60;
int secondsDur = duration % 60;
NSString *minutesString2 = (minutesDur < 10) ?
[NSString stringWithFormat:@"0%d", minutesDur] :
[NSString stringWithFormat:@"%d", minutesDur];
NSString *secondsString2 = (secondsDur < 10) ?
[NSString stringWithFormat:@"0%d", secondsDur] :
[NSString stringWithFormat:@"%d", secondsDur];
lblDuration.text = [NSString stringWithFormat:@"%@:%@", minutesString2,
secondsString2];
}