From e047a94cd7f35aaf96c857059bb4f9009dd4a9b6 Mon Sep 17 00:00:00 2001 From: Dipak Date: Mon, 12 May 2014 13:08:02 -0400 Subject: [PATCH 1/3] - updated pic width property --- SAVideoRangeSlider/SAVideoRangeSlider.h | 3 +- SAVideoRangeSlider/SAVideoRangeSlider.m | 44 ++++++++++++++++--------- VideoRangeSlider.podspec | 4 +-- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/SAVideoRangeSlider/SAVideoRangeSlider.h b/SAVideoRangeSlider/SAVideoRangeSlider.h index 7a6d598..09d0ed6 100644 --- a/SAVideoRangeSlider/SAVideoRangeSlider.h +++ b/SAVideoRangeSlider/SAVideoRangeSlider.h @@ -45,7 +45,8 @@ @property (nonatomic, strong) UIView *bottomBorder; @property (nonatomic, assign) NSInteger maxGap; @property (nonatomic, assign) NSInteger minGap; - +@property (nonatomic, assign) BOOL isPlaying; +@property (nonatomic, assign) NSInteger picWidth; - (id)initWithFrame:(CGRect)frame videoUrl:(NSURL *)videoUrl; - (void)setPopoverBubbleSize: (CGFloat) width height:(CGFloat)height; diff --git a/SAVideoRangeSlider/SAVideoRangeSlider.m b/SAVideoRangeSlider/SAVideoRangeSlider.m index 2dff742..60a4707 100644 --- a/SAVideoRangeSlider/SAVideoRangeSlider.m +++ b/SAVideoRangeSlider/SAVideoRangeSlider.m @@ -30,6 +30,7 @@ @interface SAVideoRangeSlider () @property (nonatomic, strong) AVAssetImageGenerator *imageGenerator; @property (nonatomic, strong) UIView *bgView; @property (nonatomic, strong) UIView *centerView; +@property (nonatomic, strong) UIImageView *pinView; @property (nonatomic, strong) NSURL *videoUrl; @property (nonatomic, strong) SASliderLeft *leftThumb; @property (nonatomic, strong) SASliderRight *rightThumb; @@ -62,6 +63,8 @@ - (id)initWithFrame:(CGRect)frame videoUrl:(NSURL *)videoUrl{ _videoUrl = videoUrl; +// self.pinView.hidden=YES; +// [self addSubview:self.pinView]; _topBorder = [[UIView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, SLIDER_BORDERS_SIZE)]; _topBorder.backgroundColor = [UIColor colorWithRed: 0.996 green: 0.951 blue: 0.502 alpha: 1]; @@ -141,6 +144,15 @@ - (id)initWithFrame:(CGRect)frame return self; } +- (UIImageView *)pinView{ + if(!_pinView){ + _pinView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 7,self.frame.size.height)]; + _pinView.backgroundColor=[UIColor whiteColor]; + } + return _pinView; +} + + -(void)setPopoverBubbleSize: (CGFloat) width height:(CGFloat)height{ @@ -173,6 +185,14 @@ -(void)setMinGap:(NSInteger)minGap{ - (void)delegateNotification { if ([_delegate respondsToSelector:@selector(videoRange:didChangeLeftPosition:rightPosition:)]){ + if(self.isPlaying){ + self.pinView.hidden=NO; + CGRect position=self.pinView.frame; + position.origin.x=self.leftThumb.frame.origin.x+5; + self.pinView.frame=position; + }else{ + self.pinView.hidden=YES; + } [_delegate videoRange:self didChangeLeftPosition:self.leftPosition rightPosition:self.rightPosition]; } @@ -303,19 +323,11 @@ - (void)handleCenterPan:(UIPanGestureRecognizer *)gesture - (void)layoutSubviews { CGFloat inset = _leftThumb.frame.size.width / 2; - _leftThumb.center = CGPointMake(_leftPosition+inset, _leftThumb.frame.size.height/2); - _rightThumb.center = CGPointMake(_rightPosition-inset, _rightThumb.frame.size.height/2); - _topBorder.frame = CGRectMake(_leftThumb.frame.origin.x + _leftThumb.frame.size.width, 0, _rightThumb.frame.origin.x - _leftThumb.frame.origin.x - _leftThumb.frame.size.width/2, SLIDER_BORDERS_SIZE); - _bottomBorder.frame = CGRectMake(_leftThumb.frame.origin.x + _leftThumb.frame.size.width, _bgView.frame.size.height-SLIDER_BORDERS_SIZE, _rightThumb.frame.origin.x - _leftThumb.frame.origin.x - _leftThumb.frame.size.width/2, SLIDER_BORDERS_SIZE); - - _centerView.frame = CGRectMake(_leftThumb.frame.origin.x + _leftThumb.frame.size.width, _centerView.frame.origin.y, _rightThumb.frame.origin.x - _leftThumb.frame.origin.x - _leftThumb.frame.size.width, _centerView.frame.size.height); - - CGRect frame = _popoverBubble.frame; frame.origin.x = _centerView.frame.origin.x+_centerView.frame.size.width/2-frame.size.width/2; _popoverBubble.frame = frame; @@ -337,11 +349,13 @@ -(void)getMovieFrame{ self.imageGenerator.maximumSize = CGSizeMake(_bgView.frame.size.width, _bgView.frame.size.height); } - int picWidth = 20; + int picWidth = 30; + if(self.picWidth) + picWidth=self.picWidth; // First image - NSError *error; - CMTime actualTime; + __block NSError *error; + __block CMTime actualTime; CGImageRef halfWayImage = [self.imageGenerator copyCGImageAtTime:kCMTimeZero actualTime:&actualTime error:&error]; if (halfWayImage != NULL) { UIImage *videoScreen; @@ -366,11 +380,12 @@ -(void)getMovieFrame{ NSMutableArray *allTimes = [[NSMutableArray alloc] init]; - int time4Pic = 0; - + __block int time4Pic = 0; if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0){ // Bug iOS7 - generateCGImagesAsynchronouslyForTimes - int prefreWidth=0; + + __block int prefreWidth=0; + for (int i=1, ii=1; i "MIT", :file => "LICENSE" } s.author = { "Andrei" => "andrei@solovjev.com" } s.platform = :ios, "5.0" s.requires_arc = TRUE - s.source = { :git => "git@github.com:Dipak99041012/SAVideoRangeSlider.git", :tag => "0.0.1" } + s.source = { :git => "git@github.com:Dipak99041012/SAVideoRangeSlider.git", :tag => "0.0.2" } s.source_files = "SAVideoRangeSlider/*.{h,m}" s.frameworks = "MediaPlayer", "AVFoundation", "CoreMedia","QuartzCore" end From b8988417940cd8dbc046b6ff53c8bfc617df9a99 Mon Sep 17 00:00:00 2001 From: Dipak Date: Mon, 12 May 2014 14:23:12 -0400 Subject: [PATCH 2/3] - Revert back to previous frame --- SAVideoRangeSlider/SAVideoRangeSlider.m | 30 ++++++++----------------- VideoRangeSlider.podspec | 4 ++-- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/SAVideoRangeSlider/SAVideoRangeSlider.m b/SAVideoRangeSlider/SAVideoRangeSlider.m index 60a4707..45fdbf5 100644 --- a/SAVideoRangeSlider/SAVideoRangeSlider.m +++ b/SAVideoRangeSlider/SAVideoRangeSlider.m @@ -342,6 +342,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); @@ -349,7 +350,7 @@ -(void)getMovieFrame{ self.imageGenerator.maximumSize = CGSizeMake(_bgView.frame.size.width, _bgView.frame.size.height); } - int picWidth = 30; + int picWidth = 49; if(self.picWidth) picWidth=self.picWidth; @@ -365,9 +366,9 @@ -(void)getMovieFrame{ videoScreen = [[UIImage alloc] initWithCGImage:halfWayImage]; } UIImageView *tmp = [[UIImageView alloc] initWithImage:videoScreen]; - CGRect rect=tmp.frame; - rect.size.width=picWidth; - tmp.frame=rect; +// CGRect rect=tmp.frame; +// rect.size.width=picWidth; +// tmp.frame=rect; [_bgView addSubview:tmp]; picWidth = tmp.frame.size.width; CGImageRelease(halfWayImage); @@ -384,7 +385,6 @@ -(void)getMovieFrame{ if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0){ // Bug iOS7 - generateCGImagesAsynchronouslyForTimes - __block 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; } - + tmp.frame = currentFrame; ii++; + dispatch_async(dispatch_get_main_queue(), ^{ [_bgView addSubview:tmp]; }); - - - CGImageRelease(halfWayImage); } diff --git a/VideoRangeSlider.podspec b/VideoRangeSlider.podspec index 3d00172..478db21 100644 --- a/VideoRangeSlider.podspec +++ b/VideoRangeSlider.podspec @@ -1,13 +1,13 @@ Pod::Spec.new do |s| s.name = "VideoRangeSlider" - s.version = "0.0.2" + s.version = "0.0.3" s.summary = "VideoRangeSlider" s.homepage = "https://github.com/andrei200287/SAVideoRangeSlider" s.license = { :type => "MIT", :file => "LICENSE" } s.author = { "Andrei" => "andrei@solovjev.com" } s.platform = :ios, "5.0" s.requires_arc = TRUE - s.source = { :git => "git@github.com:Dipak99041012/SAVideoRangeSlider.git", :tag => "0.0.2" } + s.source = { :git => "git@github.com:Dipak99041012/SAVideoRangeSlider.git", :tag => "0.0.3" } s.source_files = "SAVideoRangeSlider/*.{h,m}" s.frameworks = "MediaPlayer", "AVFoundation", "CoreMedia","QuartzCore" end From 6d368c26b49659e1a6fa08e35214c6dc8d6a7d71 Mon Sep 17 00:00:00 2001 From: Dipak Date: Wed, 24 Sep 2014 09:46:06 -0400 Subject: [PATCH 3/3] - remove warning --- SAVideoRangeSlider/SAVideoRangeSlider.m | 11 ++++------- .../project.pbxproj | 6 ++---- VideoRangeSlider.podspec | 6 +++--- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/SAVideoRangeSlider/SAVideoRangeSlider.m b/SAVideoRangeSlider/SAVideoRangeSlider.m index 45fdbf5..aa45813 100644 --- a/SAVideoRangeSlider/SAVideoRangeSlider.m +++ b/SAVideoRangeSlider/SAVideoRangeSlider.m @@ -124,7 +124,7 @@ - (id)initWithFrame:(CGRect)frame videoUrl:(NSURL *)videoUrl{ _bubleText.font = [UIFont boldSystemFontOfSize:20]; _bubleText.backgroundColor = [UIColor clearColor]; _bubleText.textColor = [UIColor blackColor]; - _bubleText.textAlignment = UITextAlignmentCenter; + _bubleText.textAlignment = NSTextAlignmentCenter; [_popoverBubble addSubview:_bubleText]; @@ -352,7 +352,7 @@ -(void)getMovieFrame{ int picWidth = 49; if(self.picWidth) - picWidth=self.picWidth; + picWidth= (int)self.picWidth; // First image __block NSError *error; @@ -366,9 +366,6 @@ -(void)getMovieFrame{ 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); @@ -553,8 +550,8 @@ -(NSString *)trimIntervalStr{ - (NSString *)timeToStr:(CGFloat)time { // time - seconds - NSInteger min = floor(time / 60); - NSInteger sec = floor(time - min * 60); + int min = floor(time / 60); + int sec = floor(time - min * 60); NSString *minStr = [NSString stringWithFormat:min >= 10 ? @"%i" : @"0%i", min]; NSString *secStr = [NSString stringWithFormat:sec >= 10 ? @"%i" : @"0%i", sec]; return [NSString stringWithFormat:@"%@:%@", minStr, secStr]; diff --git a/SAVideoRangeSliderExample/SAVideoRangeSliderExample.xcodeproj/project.pbxproj b/SAVideoRangeSliderExample/SAVideoRangeSliderExample.xcodeproj/project.pbxproj index c77bbec..77010f4 100644 --- a/SAVideoRangeSliderExample/SAVideoRangeSliderExample.xcodeproj/project.pbxproj +++ b/SAVideoRangeSliderExample/SAVideoRangeSliderExample.xcodeproj/project.pbxproj @@ -29,7 +29,6 @@ 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 */; }; - 9EDFED2E191D4CAE00528292 /* IMG_0073.MOV in Resources */ = {isa = PBXBuildFile; fileRef = 9EDFED2D191D4CAE00528292 /* IMG_0073.MOV */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -64,7 +63,6 @@ 842D00D716F7A68100BC2959 /* SAVideoRangeSlider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SAVideoRangeSlider.h; sourceTree = ""; }; 842D00D816F7A68100BC2959 /* SAVideoRangeSlider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SAVideoRangeSlider.m; sourceTree = ""; }; 9EDFED27191D1FAA00528292 /* VideoRangeSlider.podspec */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = VideoRangeSlider.podspec; path = ../../VideoRangeSlider.podspec; sourceTree = ""; }; - 9EDFED2D191D4CAE00528292 /* IMG_0073.MOV */ = {isa = PBXFileReference; lastKnownFileType = video.quicktime; name = IMG_0073.MOV; path = ../../../../../Desktop/IMG_0073.MOV; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -134,7 +132,6 @@ 842D008E16F7064700BC2959 /* Supporting Files */ = { isa = PBXGroup; children = ( - 9EDFED2D191D4CAE00528292 /* IMG_0073.MOV */, 9EDFED27191D1FAA00528292 /* VideoRangeSlider.podspec */, 842D00C016F70AF500BC2959 /* thaiPhuketKaronBeach.MOV */, 842D008F16F7064700BC2959 /* SAVideoRangeSliderExample-Info.plist */, @@ -223,7 +220,6 @@ 842D00A716F7064700BC2959 /* ViewController_iPad.xib in Resources */, 9EDFED28191D1FAA00528292 /* VideoRangeSlider.podspec in Resources */, 842D00C116F70AF500BC2959 /* thaiPhuketKaronBeach.MOV in Resources */, - 9EDFED2E191D4CAE00528292 /* IMG_0073.MOV in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -338,6 +334,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "SAVideoRangeSliderExample/SAVideoRangeSliderExample-Prefix.pch"; INFOPLIST_FILE = "SAVideoRangeSliderExample/SAVideoRangeSliderExample-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; }; @@ -349,6 +346,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "SAVideoRangeSliderExample/SAVideoRangeSliderExample-Prefix.pch"; INFOPLIST_FILE = "SAVideoRangeSliderExample/SAVideoRangeSliderExample-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; }; diff --git a/VideoRangeSlider.podspec b/VideoRangeSlider.podspec index 478db21..99fc5d4 100644 --- a/VideoRangeSlider.podspec +++ b/VideoRangeSlider.podspec @@ -1,13 +1,13 @@ Pod::Spec.new do |s| s.name = "VideoRangeSlider" - s.version = "0.0.3" + s.version = "0.0.5" s.summary = "VideoRangeSlider" s.homepage = "https://github.com/andrei200287/SAVideoRangeSlider" s.license = { :type => "MIT", :file => "LICENSE" } s.author = { "Andrei" => "andrei@solovjev.com" } - s.platform = :ios, "5.0" + s.platform = :ios, "6.0" s.requires_arc = TRUE - s.source = { :git => "git@github.com:Dipak99041012/SAVideoRangeSlider.git", :tag => "0.0.3" } + s.source = { :git => "git@github.com:Dipak99041012/SAVideoRangeSlider.git", :tag => "0.0.5" } s.source_files = "SAVideoRangeSlider/*.{h,m}" s.frameworks = "MediaPlayer", "AVFoundation", "CoreMedia","QuartzCore" end