Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion SAVideoRangeSlider/SAVideoRangeSlider.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
73 changes: 36 additions & 37 deletions SAVideoRangeSlider/SAVideoRangeSlider.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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];

Expand All @@ -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{

Expand Down Expand Up @@ -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];
}

Expand Down Expand Up @@ -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;
Expand All @@ -330,18 +342,21 @@ -(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);
} else {
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;
Expand All @@ -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);
Expand All @@ -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<picsCnt; i++){
time4Pic = i*picWidth;

Expand All @@ -389,42 +401,29 @@ -(void)getMovieFrame{
}



UIImageView *tmp = [[UIImageView alloc] initWithImage:videoScreen];

int all = (ii+1)*tmp.frame.size.width;


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;

currentFrame.origin.x = ii*currentFrame.size.width;
if (all > _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;
}

Expand Down Expand Up @@ -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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -64,7 +63,6 @@
842D00D716F7A68100BC2959 /* SAVideoRangeSlider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SAVideoRangeSlider.h; sourceTree = "<group>"; };
842D00D816F7A68100BC2959 /* SAVideoRangeSlider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SAVideoRangeSlider.m; sourceTree = "<group>"; };
9EDFED27191D1FAA00528292 /* VideoRangeSlider.podspec */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = VideoRangeSlider.podspec; path = ../../VideoRangeSlider.podspec; sourceTree = "<group>"; };
9EDFED2D191D4CAE00528292 /* IMG_0073.MOV */ = {isa = PBXFileReference; lastKnownFileType = video.quicktime; name = IMG_0073.MOV; path = ../../../../../Desktop/IMG_0073.MOV; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -134,7 +132,6 @@
842D008E16F7064700BC2959 /* Supporting Files */ = {
isa = PBXGroup;
children = (
9EDFED2D191D4CAE00528292 /* IMG_0073.MOV */,
9EDFED27191D1FAA00528292 /* VideoRangeSlider.podspec */,
842D00C016F70AF500BC2959 /* thaiPhuketKaronBeach.MOV */,
842D008F16F7064700BC2959 /* SAVideoRangeSliderExample-Info.plist */,
Expand Down Expand Up @@ -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;
};
Expand Down Expand Up @@ -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;
};
Expand All @@ -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;
};
Expand Down
6 changes: 3 additions & 3 deletions VideoRangeSlider.podspec
Original file line number Diff line number Diff line change
@@ -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