From 24bafd8f1492949848c88313f88d050d74b5e24a Mon Sep 17 00:00:00 2001 From: liuzhiyi1992 <55137840@qq.com> Date: Fri, 27 May 2016 22:52:12 +0800 Subject: [PATCH 1/4] fix the "No such file or directory" Error with /SAVideoRangeSlider/VideoRangeSlider.podspec: --- .../SAVideoRangeSliderExample.xcodeproj/project.pbxproj | 2 -- 1 file changed, 2 deletions(-) diff --git a/SAVideoRangeSliderExample/SAVideoRangeSliderExample.xcodeproj/project.pbxproj b/SAVideoRangeSliderExample/SAVideoRangeSliderExample.xcodeproj/project.pbxproj index cabb584..be66551 100644 --- a/SAVideoRangeSliderExample/SAVideoRangeSliderExample.xcodeproj/project.pbxproj +++ b/SAVideoRangeSliderExample/SAVideoRangeSliderExample.xcodeproj/project.pbxproj @@ -28,7 +28,6 @@ 842D00DA16F7A68100BC2959 /* SASliderLeft.m in Sources */ = {isa = PBXBuildFile; fileRef = 842D00D416F7A68100BC2959 /* SASliderLeft.m */; }; 842D00DB16F7A68100BC2959 /* SASliderRight.m in Sources */ = {isa = PBXBuildFile; fileRef = 842D00D616F7A68100BC2959 /* SASliderRight.m */; }; 842D00DC16F7A68100BC2959 /* SAVideoRangeSlider.m in Sources */ = {isa = PBXBuildFile; fileRef = 842D00D816F7A68100BC2959 /* SAVideoRangeSlider.m */; }; - 9EDFED28191D1FAA00528292 /* VideoRangeSlider.podspec in Resources */ = {isa = PBXBuildFile; fileRef = 9EDFED27191D1FAA00528292 /* VideoRangeSlider.podspec */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -218,7 +217,6 @@ 842D009E16F7064700BC2959 /* Default-568h@2x.png in Resources */, 842D00A416F7064700BC2959 /* ViewController_iPhone.xib in Resources */, 842D00A716F7064700BC2959 /* ViewController_iPad.xib in Resources */, - 9EDFED28191D1FAA00528292 /* VideoRangeSlider.podspec in Resources */, 842D00C116F70AF500BC2959 /* thaiPhuketKaronBeach.MOV in Resources */, ); runOnlyForDeploymentPostprocessing = 0; From 49ebf79dbbaf456a1365e97a65f55fc4664ccbbf Mon Sep 17 00:00:00 2001 From: liuzhiyi1992 <55137840@qq.com> Date: Fri, 27 May 2016 23:04:27 +0800 Subject: [PATCH 2/4] adjust the frame ImageView contentMode --- SAVideoRangeSlider/SAVideoRangeSlider.m | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/SAVideoRangeSlider/SAVideoRangeSlider.m b/SAVideoRangeSlider/SAVideoRangeSlider.m index 2dff742..30c682f 100644 --- a/SAVideoRangeSlider/SAVideoRangeSlider.m +++ b/SAVideoRangeSlider/SAVideoRangeSlider.m @@ -44,10 +44,11 @@ @implementation SAVideoRangeSlider #define SLIDER_BORDERS_SIZE 6.0f #define BG_VIEW_BORDERS_SIZE 3.0f +#define FRAME_IMAGEVIEW_CONTENT_MODE UIViewContentModeScaleAspectFill + - (id)initWithFrame:(CGRect)frame videoUrl:(NSURL *)videoUrl{ - self = [super initWithFrame:frame]; if (self) { @@ -351,11 +352,14 @@ -(void)getMovieFrame{ videoScreen = [[UIImage alloc] initWithCGImage:halfWayImage]; } UIImageView *tmp = [[UIImageView alloc] initWithImage:videoScreen]; + tmp.contentMode = FRAME_IMAGEVIEW_CONTENT_MODE; + [tmp.layer setMasksToBounds:YES]; + CGRect rect=tmp.frame; rect.size.width=picWidth; tmp.frame=rect; [_bgView addSubview:tmp]; - picWidth = tmp.frame.size.width; +// picWidth = tmp.frame.size.width; CGImageRelease(halfWayImage); } @@ -391,7 +395,8 @@ -(void)getMovieFrame{ UIImageView *tmp = [[UIImageView alloc] initWithImage:videoScreen]; - + tmp.contentMode = FRAME_IMAGEVIEW_CONTENT_MODE; + [tmp.layer setMasksToBounds:YES]; CGRect currentFrame = tmp.frame; @@ -456,6 +461,8 @@ -(void)getMovieFrame{ UIImageView *tmp = [[UIImageView alloc] initWithImage:videoScreen]; + tmp.contentMode = FRAME_IMAGEVIEW_CONTENT_MODE; + [tmp.layer setMasksToBounds:YES]; int all = (i+1)*tmp.frame.size.width; From dc51af3dc59a8b8ea143f999d9aa34c8c57bb88f Mon Sep 17 00:00:00 2001 From: liuzhiyi1992 <55137840@qq.com> Date: Fri, 27 May 2016 23:15:31 +0800 Subject: [PATCH 3/4] Dealing problem about image deformity --- SAVideoRangeSlider/SAVideoRangeSlider.m | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/SAVideoRangeSlider/SAVideoRangeSlider.m b/SAVideoRangeSlider/SAVideoRangeSlider.m index 30c682f..2ce05c6 100644 --- a/SAVideoRangeSlider/SAVideoRangeSlider.m +++ b/SAVideoRangeSlider/SAVideoRangeSlider.m @@ -45,7 +45,7 @@ @implementation SAVideoRangeSlider #define SLIDER_BORDERS_SIZE 6.0f #define BG_VIEW_BORDERS_SIZE 3.0f #define FRAME_IMAGEVIEW_CONTENT_MODE UIViewContentModeScaleAspectFill - +const int FRAME_PIC_WIDTH = 20; - (id)initWithFrame:(CGRect)frame videoUrl:(NSURL *)videoUrl{ @@ -57,6 +57,7 @@ - (id)initWithFrame:(CGRect)frame videoUrl:(NSURL *)videoUrl{ int thumbWidth = ceil(frame.size.width*0.05); _bgView = [[UIControl alloc] initWithFrame:CGRectMake(thumbWidth-BG_VIEW_BORDERS_SIZE, 0, frame.size.width-(thumbWidth*2)+BG_VIEW_BORDERS_SIZE*2, frame.size.height)]; + [_bgView.layer setMasksToBounds:YES]; _bgView.layer.borderColor = [UIColor grayColor].CGColor; _bgView.layer.borderWidth = BG_VIEW_BORDERS_SIZE; [self addSubview:_bgView]; @@ -331,6 +332,7 @@ -(void)getMovieFrame{ AVAsset *myAsset = [[AVURLAsset alloc] initWithURL:_videoUrl options:nil]; self.imageGenerator = [AVAssetImageGenerator assetImageGeneratorWithAsset:myAsset]; + self.imageGenerator.appliesPreferredTrackTransform = YES; if ([self isRetina]){ self.imageGenerator.maximumSize = CGSizeMake(_bgView.frame.size.width*2, _bgView.frame.size.height*2); @@ -338,7 +340,7 @@ -(void)getMovieFrame{ self.imageGenerator.maximumSize = CGSizeMake(_bgView.frame.size.width, _bgView.frame.size.height); } - int picWidth = 20; + int picWidth = FRAME_PIC_WIDTH; // First image NSError *error; @@ -355,11 +357,7 @@ -(void)getMovieFrame{ tmp.contentMode = FRAME_IMAGEVIEW_CONTENT_MODE; [tmp.layer setMasksToBounds:YES]; - CGRect rect=tmp.frame; - rect.size.width=picWidth; - tmp.frame=rect; [_bgView addSubview:tmp]; -// picWidth = tmp.frame.size.width; CGImageRelease(halfWayImage); } @@ -401,20 +399,8 @@ -(void)getMovieFrame{ CGRect currentFrame = tmp.frame; currentFrame.origin.x = ii*picWidth; - - currentFrame.size.width=picWidth; prefreWidth+=currentFrame.size.width; - - if( i == picsCnt-1){ - currentFrame.size.width-=6; - } tmp.frame = currentFrame; - int all = (ii+1)*tmp.frame.size.width; - - if (all > _bgView.frame.size.width){ - int delta = all - _bgView.frame.size.width; - currentFrame.size.width -= delta; - } ii++; From 99078d833ea3543148331cc2caada92733d8eb99 Mon Sep 17 00:00:00 2001 From: liuzhiyi1992 <55137840@qq.com> Date: Sat, 28 May 2016 21:52:10 +0800 Subject: [PATCH 4/4] include screen scale about iphone6P+ --- SAVideoRangeSlider/SAVideoRangeSlider.m | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/SAVideoRangeSlider/SAVideoRangeSlider.m b/SAVideoRangeSlider/SAVideoRangeSlider.m index 2ce05c6..0c0bb28 100644 --- a/SAVideoRangeSlider/SAVideoRangeSlider.m +++ b/SAVideoRangeSlider/SAVideoRangeSlider.m @@ -334,11 +334,8 @@ -(void)getMovieFrame{ self.imageGenerator = [AVAssetImageGenerator assetImageGeneratorWithAsset:myAsset]; self.imageGenerator.appliesPreferredTrackTransform = YES; - if ([self isRetina]){ - self.imageGenerator.maximumSize = CGSizeMake(_bgView.frame.size.width*2, _bgView.frame.size.height*2); - } else { - self.imageGenerator.maximumSize = CGSizeMake(_bgView.frame.size.width, _bgView.frame.size.height); - } + CGFloat scale = [[UIScreen mainScreen] scale]; + self.imageGenerator.maximumSize = CGSizeMake(_bgView.frame.size.width*scale, _bgView.frame.size.height*scale); int picWidth = FRAME_PIC_WIDTH; @@ -383,13 +380,7 @@ -(void)getMovieFrame{ CGImageRef halfWayImage = [self.imageGenerator copyCGImageAtTime:timeFrame actualTime:&actualTime error:&error]; - UIImage *videoScreen; - if ([self isRetina]){ - videoScreen = [[UIImage alloc] initWithCGImage:halfWayImage scale:2.0 orientation:UIImageOrientationUp]; - } else { - videoScreen = [[UIImage alloc] initWithCGImage:halfWayImage]; - } - + UIImage *videoScreen = [[UIImage alloc] initWithCGImage:halfWayImage scale:[[UIScreen mainScreen] scale] orientation:UIImageOrientationUp]; UIImageView *tmp = [[UIImageView alloc] initWithImage:videoScreen];