Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent fractions of thumbnails. #10

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
31 changes: 15 additions & 16 deletions SAVideoRangeSlider/SAVideoRangeSlider.m
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,11 @@ -(void)getMovieFrame{
self.imageGenerator.maximumSize = CGSizeMake(_bgView.frame.size.width, _bgView.frame.size.height);
}

//If you'd rather specify the number of pics, just set picsCnt manually
int picWidth = 20;
int picsCnt = ceil(_bgView.frame.size.width / picWidth);
picWidth = _bgView.frame.size.width / picsCnt;
int remainderWidth = _bgView.frame.size.width - (picsCnt * picWidth);

// First image
NSError *error;
Expand All @@ -362,17 +366,22 @@ -(void)getMovieFrame{

_durationSeconds = CMTimeGetSeconds([myAsset duration]);

int picsCnt = ceil(_bgView.frame.size.width / picWidth);

NSMutableArray *allTimes = [[NSMutableArray alloc] init];

int time4Pic = 0;
int frameOrigin = picWidth;

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;
int thisPicWidth = picWidth;
if (remainderWidth > 0)
{
thisPicWidth++;
remainderWidth--;
}
time4Pic = frameOrigin;

CMTime timeFrame = CMTimeMakeWithSeconds(_durationSeconds*time4Pic/_bgView.frame.size.width, 600);

Expand All @@ -395,21 +404,11 @@ -(void)getMovieFrame{


CGRect currentFrame = tmp.frame;
currentFrame.origin.x = ii*picWidth;

currentFrame.size.width=picWidth;
prefreWidth+=currentFrame.size.width;
currentFrame.origin.x = frameOrigin;
frameOrigin += thisPicWidth;

if( i == picsCnt-1){
currentFrame.size.width-=6;
}
currentFrame.size.width = thisPicWidth;
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++;

Expand Down