MPMoviewPlayer calculate current time during video play [closed]

别说谁变了你拦得住时间么 提交于 2019-12-11 06:24:51

问题


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?


回答1:


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




回答2:


try below code

CGFloat currentPlayedTime = [movieController currentPlaybackTime];

hope its helpfull.




回答3:


It may be helpful . Take the dates When it is started and stopped then do this .

NSDateFormatter *df = [[[NSDateFormatter alloc] init] autorelease];
[df setDateFormat:@"HH:mm"];
NSDate *date1 = [df dateFromString:@"14:10"];// Startdate
NSDate *date2 = [df dateFromString:@"18:09"];// Stop date
NSTimeInterval interval = [date2 timeIntervalSinceDate:date1];
int hours = (int)interval / 3600;             // integer division to get the hours part
int minutes = (interval - (hours*3600)) / 60; // interval minus hours part (in seconds) divided by 60 yields minutes
NSString *timeDiff = [NSString stringWithFormat:@"%d:%02d", hours, minutes];


来源:https://stackoverflow.com/questions/18400342/mpmoviewplayer-calculate-current-time-during-video-play

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!