|
@@ -11,6 +11,9 @@
|
|
#import "AliyunMediaConfig.h"
|
|
#import "AliyunMediaConfig.h"
|
|
#import "AVC_ShortVideo_Config.h"
|
|
#import "AVC_ShortVideo_Config.h"
|
|
#import "AlivcMacro.h"
|
|
#import "AlivcMacro.h"
|
|
|
|
+#import "UIColor+AlivcHelper.h"
|
|
|
|
+
|
|
|
|
+#define kCutSegment 12
|
|
|
|
|
|
@interface AliyunCropThumbnailView ()
|
|
@interface AliyunCropThumbnailView ()
|
|
@property (nonatomic, strong) UICollectionView *collectionView;
|
|
@property (nonatomic, strong) UICollectionView *collectionView;
|
|
@@ -23,7 +26,6 @@
|
|
@property (nonatomic, strong) UIImageView *imageViewLeftMask;
|
|
@property (nonatomic, strong) UIImageView *imageViewLeftMask;
|
|
@property (nonatomic, strong) UIImageView *imageViewRight;
|
|
@property (nonatomic, strong) UIImageView *imageViewRight;
|
|
@property (nonatomic, strong) UIImageView *imageViewRightMask;
|
|
@property (nonatomic, strong) UIImageView *imageViewRightMask;
|
|
-@property (nonatomic, strong) UIImageView *imageViewBackground;
|
|
|
|
@property (nonatomic, strong) UIImageView *imageViewSelected;
|
|
@property (nonatomic, strong) UIImageView *imageViewSelected;
|
|
@property (nonatomic, strong) UIImageView *progressView;
|
|
@property (nonatomic, strong) UIImageView *progressView;
|
|
|
|
|
|
@@ -47,7 +49,7 @@
|
|
self = [super initWithFrame:frame];
|
|
self = [super initWithFrame:frame];
|
|
if (self) {
|
|
if (self) {
|
|
_cutInfo = cutInfo;
|
|
_cutInfo = cutInfo;
|
|
- _imagesArray = [NSMutableArray arrayWithCapacity:8];
|
|
|
|
|
|
+ _imagesArray = [NSMutableArray arrayWithCapacity:kCutSegment];
|
|
[self setupCollectionView];
|
|
[self setupCollectionView];
|
|
[self setupSubviews];
|
|
[self setupSubviews];
|
|
}
|
|
}
|
|
@@ -56,11 +58,11 @@
|
|
|
|
|
|
- (void)setupCollectionView {
|
|
- (void)setupCollectionView {
|
|
UICollectionViewFlowLayout *followLayout = [[UICollectionViewFlowLayout alloc] init];
|
|
UICollectionViewFlowLayout *followLayout = [[UICollectionViewFlowLayout alloc] init];
|
|
- followLayout.itemSize = CGSizeMake(ScreenWidth / 8.0 , 72);
|
|
|
|
|
|
+ followLayout.itemSize = CGSizeMake((ScreenWidth-28)/kCutSegment , 72);
|
|
followLayout.minimumLineSpacing = 0;
|
|
followLayout.minimumLineSpacing = 0;
|
|
followLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
|
|
followLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
|
|
|
|
|
|
- _collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 38, ScreenWidth, 72) collectionViewLayout:followLayout];
|
|
|
|
|
|
+ _collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 38, ScreenWidth-28, 72) collectionViewLayout:followLayout];
|
|
_collectionView.dataSource = (id<UICollectionViewDataSource>)self;
|
|
_collectionView.dataSource = (id<UICollectionViewDataSource>)self;
|
|
[_collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
|
|
[_collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
|
|
[self addSubview:_collectionView];
|
|
[self addSubview:_collectionView];
|
|
@@ -73,26 +75,25 @@
|
|
_progressView.center = CGPointMake(0, CGRectGetMidY(self.bounds) + 19);
|
|
_progressView.center = CGPointMake(0, CGRectGetMidY(self.bounds) + 19);
|
|
[self addSubview:_progressView];
|
|
[self addSubview:_progressView];
|
|
|
|
|
|
- _durationLabel = [[UILabel alloc] initWithFrame:CGRectMake(14, 0, ScreenWidth - 200, 18)];
|
|
|
|
|
|
+ _durationLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth - 200, 18)];
|
|
_durationLabel.textColor = [UIColor whiteColor];
|
|
_durationLabel.textColor = [UIColor whiteColor];
|
|
_durationLabel.textAlignment = UITextAlignmentLeft;
|
|
_durationLabel.textAlignment = UITextAlignmentLeft;
|
|
_durationLabel.font = [UIFont systemFontOfSize:13];
|
|
_durationLabel.font = [UIFont systemFontOfSize:13];
|
|
[self addSubview:_durationLabel];
|
|
[self addSubview:_durationLabel];
|
|
|
|
|
|
- _imageViewWith = ScreenWidth / 8.0 * 0.35;
|
|
|
|
|
|
+ _imageViewWith = 15;
|
|
_imageViewLeft = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"video_edit_left"]];
|
|
_imageViewLeft = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"video_edit_left"]];
|
|
- _imageViewLeft.frame = CGRectMake(0, 38, 15, 72);
|
|
|
|
|
|
+ _imageViewLeft.frame = CGRectMake(0, 38, _imageViewWith, 72);
|
|
_imageViewLeft.userInteractionEnabled = YES;
|
|
_imageViewLeft.userInteractionEnabled = YES;
|
|
_imageViewRight = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"video_edit_right"]];
|
|
_imageViewRight = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"video_edit_right"]];
|
|
- _imageViewRight.frame = CGRectMake(ScreenWidth-28-15, 38, 15, 72);
|
|
|
|
|
|
+ _imageViewRight.frame = CGRectMake(ScreenWidth-28-15, 38, _imageViewWith, 72);
|
|
_imageViewRight.userInteractionEnabled = YES;
|
|
_imageViewRight.userInteractionEnabled = YES;
|
|
|
|
|
|
|
|
+ _topLineView = [[UIImageView alloc]initWithFrame:CGRectMake(_imageViewWith - 3 , 38, ScreenWidth-28 - 2*_imageViewWith+6, 3)];
|
|
|
|
+ _topLineView.backgroundColor = [UIColor colorWithHexString:@"#62CC74"];
|
|
|
|
|
|
- _topLineView = [[UIImageView alloc]initWithFrame:CGRectMake(_imageViewWith - 3 , 38, ScreenWidth - _imageViewWith *2 + 6, 3)];
|
|
|
|
- _topLineView.backgroundColor = [AliyunIConfig config].cutTopLineColor;
|
|
|
|
-
|
|
|
|
- _underLineView = [[UIImageView alloc]initWithFrame:CGRectMake(_imageViewWith - 3, _imageViewLeft.frame.size.height + 38 - 3 , ScreenWidth - _imageViewWith *2 + 6, 3)];
|
|
|
|
- _underLineView.backgroundColor = [AliyunIConfig config].cutBottomLineColor;
|
|
|
|
|
|
+ _underLineView = [[UIImageView alloc]initWithFrame:CGRectMake(_imageViewWith - 3, _imageViewLeft.frame.size.height + 38 - 3 , ScreenWidth-28 - 2*_imageViewWith+6, 3)];
|
|
|
|
+ _underLineView.backgroundColor = [UIColor colorWithHexString:@"#62CC74"];
|
|
|
|
|
|
[self addSubview:_topLineView];
|
|
[self addSubview:_topLineView];
|
|
[self addSubview:_underLineView];
|
|
[self addSubview:_underLineView];
|
|
@@ -111,11 +112,6 @@
|
|
|
|
|
|
[self addSubview:_imageViewLeftMask];
|
|
[self addSubview:_imageViewLeftMask];
|
|
[self addSubview:_imageViewRightMask];
|
|
[self addSubview:_imageViewRightMask];
|
|
-
|
|
|
|
- _imageViewBackground = [[UIImageView alloc] initWithImage:[AliyunImage imageNamed:@"paster_time_edit_slider_bg"]];
|
|
|
|
- _imageViewBackground.frame = CGRectMake(CGRectGetMaxX(_imageViewLeft.frame), CGRectGetMinY(_imageViewLeft.frame), CGRectGetMinX(_imageViewRight.frame) - CGRectGetMaxX(_imageViewLeft.frame), 72);
|
|
|
|
- [self addSubview:_imageViewBackground];
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- (void)loadThumbnailData {
|
|
- (void)loadThumbnailData {
|
|
@@ -124,7 +120,7 @@
|
|
CMTime startTime = kCMTimeZero;
|
|
CMTime startTime = kCMTimeZero;
|
|
NSMutableArray *array = [NSMutableArray array];
|
|
NSMutableArray *array = [NSMutableArray array];
|
|
// CMTime addTime = CMTimeMake(1000,1000);
|
|
// CMTime addTime = CMTimeMake(1000,1000);
|
|
- CGFloat d = _cutInfo.sourceDuration / 7.0;
|
|
|
|
|
|
+ CGFloat d = _cutInfo.sourceDuration / (kCutSegment-1);
|
|
int intd = d * 100;
|
|
int intd = d * 100;
|
|
float fd = intd / 100.0;
|
|
float fd = intd / 100.0;
|
|
CMTime addTime = CMTimeMakeWithSeconds(fd, 1000);
|
|
CMTime addTime = CMTimeMakeWithSeconds(fd, 1000);
|
|
@@ -157,7 +153,7 @@
|
|
- (void)updateProgressViewWithProgress:(CGFloat)progress {
|
|
- (void)updateProgressViewWithProgress:(CGFloat)progress {
|
|
CGPoint center = _progressView.center;
|
|
CGPoint center = _progressView.center;
|
|
|
|
|
|
- CGFloat newX = progress *ScreenWidth;
|
|
|
|
|
|
+ CGFloat newX = progress *(ScreenWidth-28);
|
|
if (newX < center.x ) {
|
|
if (newX < center.x ) {
|
|
center.x = newX;
|
|
center.x = newX;
|
|
|
|
|
|
@@ -233,7 +229,6 @@
|
|
_imageViewLeftMask.frame = maskFrame;
|
|
_imageViewLeftMask.frame = maskFrame;
|
|
|
|
|
|
_cutInfo.startTime = left;
|
|
_cutInfo.startTime = left;
|
|
- _imageViewBackground.frame = CGRectMake(CGRectGetMaxX(_imageViewLeft.frame), CGRectGetMinY(_imageViewLeft.frame), CGRectGetMinX(_imageViewRight.frame) - CGRectGetMaxX(_imageViewLeft.frame), 72);
|
|
|
|
_durationLabel.text = [NSString stringWithFormat:@"已选取%.1fs",_cutInfo.endTime - _cutInfo.startTime];
|
|
_durationLabel.text = [NSString stringWithFormat:@"已选取%.1fs",_cutInfo.endTime - _cutInfo.startTime];
|
|
if ([_delegate respondsToSelector:@selector(cutBarDidMovedToTime:)]) {
|
|
if ([_delegate respondsToSelector:@selector(cutBarDidMovedToTime:)]) {
|
|
[_delegate cutBarDidMovedToTime:left];
|
|
[_delegate cutBarDidMovedToTime:left];
|
|
@@ -251,7 +246,6 @@
|
|
maskFrame.origin.x = frame.origin.x + frame.size.width;
|
|
maskFrame.origin.x = frame.origin.x + frame.size.width;
|
|
maskFrame.size.width = ScreenWidth - maskFrame.origin.x;
|
|
maskFrame.size.width = ScreenWidth - maskFrame.origin.x;
|
|
_imageViewRightMask.frame = maskFrame;
|
|
_imageViewRightMask.frame = maskFrame;
|
|
- _imageViewBackground.frame = CGRectMake(CGRectGetMaxX(_imageViewLeft.frame), CGRectGetMinY(_imageViewLeft.frame), CGRectGetMinX(_imageViewRight.frame) - CGRectGetMaxX(_imageViewLeft.frame), 72);
|
|
|
|
_durationLabel.text = [NSString stringWithFormat:@"已选取%.1fs", _cutInfo.endTime - _cutInfo.startTime];
|
|
_durationLabel.text = [NSString stringWithFormat:@"已选取%.1fs", _cutInfo.endTime - _cutInfo.startTime];
|
|
if ([_delegate respondsToSelector:@selector(cutBarDidMovedToTime:)]) {
|
|
if ([_delegate respondsToSelector:@selector(cutBarDidMovedToTime:)]) {
|
|
[_delegate cutBarDidMovedToTime:right];
|
|
[_delegate cutBarDidMovedToTime:right];
|