视频播放读取进度条MPMoviePlayerController

NSString *moviePath = [[NSBundlemainBundle] pathForResource:@"video_002"ofType:@"mp4"];

m_pMoviePlayer = [[MPMoviePlayerControlleralloc] initWithContentURL:[NSURLfileURLWithPath:moviePath]];


                    NSDictionary *opts = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO]
                                                                     forKey:AVURLAssetPreferPreciseDurationAndTimingKey];                    
                    AVURLAsset *urlAsset = [AVURLAsset URLAssetWithURL:movieURL options:opts];  // 初始化视频媒体文件
                    int minute = 0, second = 0; 
                    second = urlAsset.duration.value / urlAsset.duration.timescale; // 获取视频总时长,单位秒
                    //NSLog(@"movie duration : %d", second);                    
                    if (second >= 60) {
                        int index = second / 60;
                        minute = index;
                        second = second - index*60;                        
                    }    

注意添加AVFoundation框架
2011-12-20 10:03


你可能感兴趣的:(视频播放读取进度条MPMoviePlayerController)