|
@@ -10,9 +10,13 @@
|
|
|
#import "AVAsset+VideoInfo.h"
|
|
|
#import "AVC_ShortVideo_Config.h"
|
|
|
#import <AVFoundation/AVFoundation.h>
|
|
|
+#import "AlivcMacro.h"
|
|
|
+
|
|
|
+#define kCutSegment 12
|
|
|
+
|
|
|
@interface AliyunCoverPickView ()
|
|
|
@property(nonatomic, strong) UICollectionView *collectionView;
|
|
|
-@property(nonatomic, strong) UIImageView *progressView;
|
|
|
+@property(nonatomic, strong) UIView *progressView;
|
|
|
@property(nonatomic, strong) NSMutableArray *imagesArray;
|
|
|
@property(nonatomic, strong) AVAssetImageGenerator *imageGenerator;
|
|
|
@property(nonatomic, strong) AVAssetImageGenerator *pickGenerator;
|
|
@@ -25,35 +29,38 @@
|
|
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
|
self = [super initWithFrame:frame];
|
|
|
if (self) {
|
|
|
- _imagesArray = [NSMutableArray arrayWithCapacity:8];
|
|
|
+ _imagesArray = [NSMutableArray arrayWithCapacity:kCutSegment];
|
|
|
[self setupSubviews];
|
|
|
}
|
|
|
return self;
|
|
|
}
|
|
|
|
|
|
- (void)setupSubviews {
|
|
|
- UICollectionViewFlowLayout *followLayout =
|
|
|
+ UICollectionViewFlowLayout *followLayout =
|
|
|
[[UICollectionViewFlowLayout alloc] init];
|
|
|
- followLayout.itemSize =
|
|
|
- CGSizeMake(CGRectGetHeight(self.frame), CGRectGetHeight(self.frame));
|
|
|
- followLayout.minimumLineSpacing = 0;
|
|
|
- followLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
|
|
|
+ followLayout.itemSize = CGSizeMake((ScreenWidth-28)/kCutSegment, 69);
|
|
|
+ followLayout.minimumLineSpacing = 0;
|
|
|
+ followLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
|
|
|
|
|
|
- _collectionView = [[UICollectionView alloc]
|
|
|
+ _collectionView = [[UICollectionView alloc]
|
|
|
initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.frame),
|
|
|
CGRectGetHeight(self.frame))
|
|
|
collectionViewLayout:followLayout];
|
|
|
- _collectionView.dataSource = (id<UICollectionViewDataSource>)self;
|
|
|
- [_collectionView registerClass:[UICollectionViewCell class]
|
|
|
+ _collectionView.dataSource = (id<UICollectionViewDataSource>)self;
|
|
|
+ [_collectionView registerClass:[UICollectionViewCell class]
|
|
|
forCellWithReuseIdentifier:@"cell"];
|
|
|
- [self addSubview:_collectionView];
|
|
|
- UIView *view = [[UIView alloc] initWithFrame:self.bounds];
|
|
|
- view.backgroundColor = [UIColor clearColor];
|
|
|
- [self addSubview:view];
|
|
|
- _progressView = [[UIImageView alloc]
|
|
|
- initWithImage:[AliyunImage imageNamed:@"icon_cover_slide"]];
|
|
|
- _progressView.frame = CGRectMake(0, 0, 4, CGRectGetHeight(self.frame));
|
|
|
- [view addSubview:_progressView];
|
|
|
+ [self addSubview:_collectionView];
|
|
|
+ UIView *view = [[UIView alloc] initWithFrame:self.bounds];
|
|
|
+ view.backgroundColor = [UIColor clearColor];
|
|
|
+ [self addSubview:view];
|
|
|
+
|
|
|
+ _progressView = [[UIView alloc] init];
|
|
|
+ _progressView.frame = CGRectMake(0, 0, (ScreenWidth-28)/kCutSegment, CGRectGetHeight(self.frame));
|
|
|
+ _progressView.layer.borderWidth = 2;
|
|
|
+ _progressView.layer.borderColor = [UIColor whiteColor].CGColor;
|
|
|
+ _progressView.layer.cornerRadius = 4;
|
|
|
+ _progressView.layer.masksToBounds = YES;
|
|
|
+ [view addSubview:_progressView];
|
|
|
}
|
|
|
|
|
|
- (void)parseAsset {
|
|
@@ -70,7 +77,7 @@
|
|
|
|
|
|
CMTime startTime = kCMTimeZero;
|
|
|
NSMutableArray *array = [NSMutableArray array];
|
|
|
- CMTime addTime = CMTimeMake(_duration * 1000 / 8.0f, 1000);
|
|
|
+ CMTime addTime = CMTimeMake(_duration * 1000 / kCutSegment, 1000);
|
|
|
|
|
|
CMTime endTime = CMTimeMake(_duration * 1000, 1000);
|
|
|
while (CMTIME_COMPARE_INLINE(startTime, <, endTime)) {
|