I am making an iphone app in which playing video from url server it works fine but i want lets say video is for 3 minutes or 4 minutes how much time user viewed video like it played video for 1 minuted and stoped likewise.
NSURL *url = [NSURL URLWithString:newString];
NSLog(@"New File name is %@",newString);
mp = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
[[mp moviePlayer] prepareToPlay];
[[mp moviePlayer] setUseApplicationAudioSession:NO];
[[mp moviePlayer] setShouldAutoplay:YES];
[[mp moviePlayer] setControlStyle:2];
//[[mp moviePlayer] setRepeatMode:MPMovieRepeatModeOne];
[self presentMoviePlayerViewControllerAnimated:mp];
I think, you can start
NSTimer
at the time of presentingMPMoviePlayerViewController
and listen the notificationMPMoviePlayerPlaybackDidFinishNotification
orMPMoviePlayerPlaybackDidFinishReasonUserInfoKey
and calculate the time.EDIT
Best way is to access MPMediaPlayback's
currentPlaybackTime
property usingMPMoviePlayerPlaybackDidFinishNotification
notificationthis will give you the actual time. In your case you can access this property as