获取网上流视频总时长和当前播放时长
2012-11-22 15:13
405 查看
1.获取网上流视频总时长
NSURL *movieURL = [NSURL URLWithString:self.myVideoUrlStr];
NSDictionary *opts = [NSDictionarydictionaryWithObject: [NSNumbernumberWithBool:NO]forKey:AVURLAssetPreferPreciseDurationAndTimingKey];
AVURLAsset *urlAsset = [AVURLAsset URLAssetWithURL:movieURL options:opts]; // 初始化视频媒体文件
int minute = 0, second = 0;
second = urlAsset.duration.value / urlAsset.duration.timescale; // 获取视频总时长,单位秒
if (second >= 60) {
int index = second / 60;
minute = index;
second = second - index*60;
}
2.当前播放时长
- (void) movieFinishedCallback:(NSNotification*) notification {
NSLog(@"111111111视频播放完毕");
MPMoviePlayerController *player = [notification object];
[player stop];
[[NSNotificationCenterdefaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification object:player];
NSArray *events = player.accessLog.events;
int count = events.count;
//NSLog(@"events count = %d", count);
for (int i = 0; i < count; ++i) {
MPMovieAccessLogEvent *currenEvent = [events objectAtIndex:i];
// double byts = currenEvent.indicatedBitrate ;
// NSLog(@"5555555==视频播放当前时间======%f",currenEvent.durationWatched);
videotimedurationWatched = currenEvent.durationWatched;
}
}
NSURL *movieURL = [NSURL URLWithString:self.myVideoUrlStr];
NSDictionary *opts = [NSDictionarydictionaryWithObject: [NSNumbernumberWithBool:NO]forKey:AVURLAssetPreferPreciseDurationAndTimingKey];
AVURLAsset *urlAsset = [AVURLAsset URLAssetWithURL:movieURL options:opts]; // 初始化视频媒体文件
int minute = 0, second = 0;
second = urlAsset.duration.value / urlAsset.duration.timescale; // 获取视频总时长,单位秒
if (second >= 60) {
int index = second / 60;
minute = index;
second = second - index*60;
}
2.当前播放时长
- (void) movieFinishedCallback:(NSNotification*) notification {
NSLog(@"111111111视频播放完毕");
MPMoviePlayerController *player = [notification object];
[player stop];
[[NSNotificationCenterdefaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification object:player];
NSArray *events = player.accessLog.events;
int count = events.count;
//NSLog(@"events count = %d", count);
for (int i = 0; i < count; ++i) {
MPMovieAccessLogEvent *currenEvent = [events objectAtIndex:i];
// double byts = currenEvent.indicatedBitrate ;
// NSLog(@"5555555==视频播放当前时间======%f",currenEvent.durationWatched);
videotimedurationWatched = currenEvent.durationWatched;
}
}
相关文章推荐
- 获取当前视频播放时间
- 页面里嵌入播放器,并获取当前视频的播放总时间
- 获取当前视频播放时间
- iOS-获取视频长度和当前播放时间
- 【求助】winfrom怎么获取视频当前播放时间
- 网上获取视频,可播放
- iOS-获取视频长度和当前播放时间
- Android 获取视频缩略图的 与播放视频的冲突
- 请教:Android正播放视频时的解码输出流如何获取?
- 安卓webview html5 自动播放本地视频,网上视频,可以循环播放
- H5 video 标签 播放事件 视频加载完成事件 获取视频播放进度时间
- 激活当前屏幕保护及获取网上计算机名及其IP地址
- 初学OpenCV3,运行编程入门上读取并播放视频的原版程序,编译通过但是没有任何输出,已按网上博主各种方法试,还是没有结果,大家看怎么解决?
- iOS开发:获取一个视频、音频文件的播放时长
- Android 获取播放视频的相关 内容,  分辨率, 方向,作者信息
- 用MCI处置WAV视频时,怎样才能让视频在当前窗口播放
- C#获取视频文件播放长度
- iOS 获取本地视频播放路径
- iOS开发——获取UIWebView中视频的长度与播放进度等信息
- android videoview播放视频前获取视频时长(根据视频路径获取)