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?
我想根据播放的视频数来计算当前时间,我很困惑使用durationWatched的属性,任何人都可以帮助我该怎么办?或者如何获取YouTube视频的当前时间?
3 个解决方案
#1
3
I have made a simple category on MPMoviePlayerController
我在MPMoviePlayerController上做了一个简单的类别
You can get the current playback time using the currentTimeMonitor method:
您可以使用currentTimeMonitor方法获取当前播放时间:
[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:
github上有一个存储库:
https://github.com/AlbanPerli/MPMoviePlayerController-CurrentPlybackTimeMonitor
#2
3
try below code
尝试以下代码
CGFloat currentPlayedTime = [movieController currentPlaybackTime];
hope its helpfull.
希望它有所帮助。
#3
0
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];
#1
3
I have made a simple category on MPMoviePlayerController
我在MPMoviePlayerController上做了一个简单的类别
You can get the current playback time using the currentTimeMonitor method:
您可以使用currentTimeMonitor方法获取当前播放时间:
[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:
github上有一个存储库:
https://github.com/AlbanPerli/MPMoviePlayerController-CurrentPlybackTimeMonitor
#2
3
try below code
尝试以下代码
CGFloat currentPlayedTime = [movieController currentPlaybackTime];
hope its helpfull.
希望它有所帮助。
#3
0
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];