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..aa45813 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]; @@ -121,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]; @@ -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; @@ -330,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); @@ -337,11 +350,13 @@ -(void)getMovieFrame{ self.imageGenerator.maximumSize = CGSizeMake(_bgView.frame.size.width, _bgView.frame.size.height); } - int picWidth = 20; + int picWidth = 49; + if(self.picWidth) + picWidth= (int)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; @@ -351,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); @@ -366,11 +378,11 @@ -(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; + + 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); } - return; } @@ -551,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 4f46c8e..99fc5d4 100644 --- a/VideoRangeSlider.podspec +++ b/VideoRangeSlider.podspec @@ -1,13 +1,13 @@ Pod::Spec.new do |s| s.name = "VideoRangeSlider" - s.version = "0.0.1" + 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.1" } + 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