diff --git a/SAVideoRangeSlider/SAVideoRangeSlider.m b/SAVideoRangeSlider/SAVideoRangeSlider.m index 2dff742..ec89b81 100644 --- a/SAVideoRangeSlider/SAVideoRangeSlider.m +++ b/SAVideoRangeSlider/SAVideoRangeSlider.m @@ -325,8 +325,8 @@ - (void)layoutSubviews #pragma mark - Video - --(void)getMovieFrame{ +- (void)getMovieFrame +{ AVAsset *myAsset = [[AVURLAsset alloc] initWithURL:_videoUrl options:nil]; self.imageGenerator = [AVAssetImageGenerator assetImageGeneratorWithAsset:myAsset]; @@ -337,108 +337,23 @@ -(void)getMovieFrame{ self.imageGenerator.maximumSize = CGSizeMake(_bgView.frame.size.width, _bgView.frame.size.height); } + // Make Times int picWidth = 20; - - // First image - NSError *error; - CMTime actualTime; - CGImageRef halfWayImage = [self.imageGenerator copyCGImageAtTime:kCMTimeZero actualTime:&actualTime error:&error]; - if (halfWayImage != NULL) { - UIImage *videoScreen; - if ([self isRetina]){ - videoScreen = [[UIImage alloc] initWithCGImage:halfWayImage scale:2.0 orientation:UIImageOrientationUp]; - } else { - videoScreen = [[UIImage alloc] initWithCGImage:halfWayImage]; - } - UIImageView *tmp = [[UIImageView alloc] initWithImage:videoScreen]; - CGRect rect=tmp.frame; - rect.size.width=picWidth; - tmp.frame=rect; - [_bgView addSubview:tmp]; - picWidth = tmp.frame.size.width; - CGImageRelease(halfWayImage); - } - - _durationSeconds = CMTimeGetSeconds([myAsset duration]); - int picsCnt = ceil(_bgView.frame.size.width / picWidth); - NSMutableArray *allTimes = [[NSMutableArray alloc] init]; - int time4Pic = 0; - - if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0){ - // Bug iOS7 - generateCGImagesAsynchronouslyForTimes - int prefreWidth=0; - for (int i=1, ii=1; i _bgView.frame.size.width){ - int delta = all - _bgView.frame.size.width; - currentFrame.size.width -= delta; - } - - ii++; - - dispatch_async(dispatch_get_main_queue(), ^{ - [_bgView addSubview:tmp]; - }); - - - - - CGImageRelease(halfWayImage); - - } - - - return; - } - - for (int i=1; i _bgView.frame.size.width){ - int delta = all - _bgView.frame.size.width; - currentFrame.size.width -= delta; - } - tmp.frame = currentFrame; - i++; - dispatch_async(dispatch_get_main_queue(), ^{ + UIImageView *tmp = [[UIImageView alloc] init]; + tmp.clipsToBounds = YES; + tmp.frame = CGRectMake(i*realwidth, 0, realwidth, _bgView.bounds.size.height); + tmp.contentMode = UIViewContentModeScaleAspectFill; + tmp.image = videoScreen; + + //NSLog(@"FRAME - %f %f %f %f %@",tmp.frame.origin.x, tmp.frame.origin.y, tmp.frame.size.width, tmp.frame.size.height, [NSValue valueWithCMTime:actualTime]); + + i++; [_bgView addSubview:tmp]; }); - } if (result == AVAssetImageGeneratorFailed) { @@ -486,7 +393,6 @@ -(void)getMovieFrame{ - #pragma mark - Properties - (CGFloat)leftPosition