Search code examples
iphoneiosyoutubempmovieplayercontroller

MPMoviewPlayer calculate current time during video play


i want to calculate current time based on how much video is played, i am confused to use the property of durationWatched, can any one help me what should i do? or how to get current time of youtube video?


Solution

  • I have made a simple category on MPMoviePlayerController

    You can get the current playback time using the currentTimeMonitor method:

    [self.moviePlayerController currentTimeMonitor:^{
      NSLog(@"Current time %i",[moviePlayerController.lastRecordedPlaybackTime intValue]);            
    }];
    

    A timer call the block every second to give you the current playbacktime.

    There is a repository on github:

    https://github.com/AlbanPerli/MPMoviePlayerController-CurrentPlybackTimeMonitor