Преглед на файлове

coverController --> to be bridge

Chris преди 5 години
родител
ревизия
1c6789b6ac

+ 50 - 16
RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj

@@ -407,6 +407,9 @@
 		BD0FAA4322C465F500DDFB37 /* AlivcCoverImageSelectedView.m in Sources */ = {isa = PBXBuildFile; fileRef = BD0FAA3F22C465F500DDFB37 /* AlivcCoverImageSelectedView.m */; };
 		BD0FAA4922C4663100DDFB37 /* AlivcEditItemModel.m in Sources */ = {isa = PBXBuildFile; fileRef = BD0FAA4622C4663000DDFB37 /* AlivcEditItemModel.m */; };
 		BD0FAA4A22C4663100DDFB37 /* AlivcEditItemManager.m in Sources */ = {isa = PBXBuildFile; fileRef = BD0FAA4822C4663100DDFB37 /* AlivcEditItemManager.m */; };
+		BD0FAA4F22C474D400DDFB37 /* AliyunCoverPickViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BD0FAA4E22C474D400DDFB37 /* AliyunCoverPickViewController.m */; };
+		BD0FAA5322C4750A00DDFB37 /* AliyunCoverPickView.m in Sources */ = {isa = PBXBuildFile; fileRef = BD0FAA5222C4750A00DDFB37 /* AliyunCoverPickView.m */; };
+		BD0FAA5622C4752C00DDFB37 /* AliyunPublishTopView.m in Sources */ = {isa = PBXBuildFile; fileRef = BD0FAA5522C4752C00DDFB37 /* AliyunPublishTopView.m */; };
 		BD108C9322A60C2100837DAB /* HGImageCompleteButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD108C8E22A60C2100837DAB /* HGImageCompleteButton.swift */; };
 		BD108C9422A60C2100837DAB /* HGImageCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD108C8F22A60C2100837DAB /* HGImageCollectionViewController.swift */; };
 		BD108C9522A60C2100837DAB /* HGImageCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD108C9022A60C2100837DAB /* HGImageCollectionViewCell.swift */; };
@@ -1060,6 +1063,12 @@
 		BD0FAA4622C4663000DDFB37 /* AlivcEditItemModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AlivcEditItemModel.m; sourceTree = "<group>"; };
 		BD0FAA4722C4663000DDFB37 /* AlivcEditItemManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AlivcEditItemManager.h; sourceTree = "<group>"; };
 		BD0FAA4822C4663100DDFB37 /* AlivcEditItemManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AlivcEditItemManager.m; sourceTree = "<group>"; };
+		BD0FAA4D22C474D400DDFB37 /* AliyunCoverPickViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AliyunCoverPickViewController.h; sourceTree = "<group>"; };
+		BD0FAA4E22C474D400DDFB37 /* AliyunCoverPickViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AliyunCoverPickViewController.m; sourceTree = "<group>"; };
+		BD0FAA5122C4750900DDFB37 /* AliyunCoverPickView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AliyunCoverPickView.h; sourceTree = "<group>"; };
+		BD0FAA5222C4750A00DDFB37 /* AliyunCoverPickView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AliyunCoverPickView.m; sourceTree = "<group>"; };
+		BD0FAA5422C4752C00DDFB37 /* AliyunPublishTopView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AliyunPublishTopView.h; sourceTree = "<group>"; };
+		BD0FAA5522C4752C00DDFB37 /* AliyunPublishTopView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AliyunPublishTopView.m; sourceTree = "<group>"; };
 		BD108C8E22A60C2100837DAB /* HGImageCompleteButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HGImageCompleteButton.swift; sourceTree = "<group>"; };
 		BD108C8F22A60C2100837DAB /* HGImageCollectionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HGImageCollectionViewController.swift; sourceTree = "<group>"; };
 		BD108C9022A60C2100837DAB /* HGImageCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HGImageCollectionViewCell.swift; sourceTree = "<group>"; };
@@ -4143,6 +4152,35 @@
 			path = Model;
 			sourceTree = "<group>";
 		};
+		BD0FAA4B22C474A500DDFB37 /* VideoCoverPick */ = {
+			isa = PBXGroup;
+			children = (
+				BD0FAA4C22C474C700DDFB37 /* Controller */,
+				BD0FAA5022C474F200DDFB37 /* View */,
+			);
+			path = VideoCoverPick;
+			sourceTree = "<group>";
+		};
+		BD0FAA4C22C474C700DDFB37 /* Controller */ = {
+			isa = PBXGroup;
+			children = (
+				BD0FAA4D22C474D400DDFB37 /* AliyunCoverPickViewController.h */,
+				BD0FAA4E22C474D400DDFB37 /* AliyunCoverPickViewController.m */,
+			);
+			path = Controller;
+			sourceTree = "<group>";
+		};
+		BD0FAA5022C474F200DDFB37 /* View */ = {
+			isa = PBXGroup;
+			children = (
+				BD0FAA5122C4750900DDFB37 /* AliyunCoverPickView.h */,
+				BD0FAA5222C4750A00DDFB37 /* AliyunCoverPickView.m */,
+				BD0FAA5422C4752C00DDFB37 /* AliyunPublishTopView.h */,
+				BD0FAA5522C4752C00DDFB37 /* AliyunPublishTopView.m */,
+			);
+			path = View;
+			sourceTree = "<group>";
+		};
 		BD108C8D22A60A2000837DAB /* HGImagePicker */ = {
 			isa = PBXGroup;
 			children = (
@@ -4707,7 +4745,6 @@
 			children = (
 				BD61227E22C3605B00D3F513 /* Models */,
 				BD61228322C3605B00D3F513 /* Manager */,
-				BD61228E22C3605B00D3F513 /* Controllers */,
 				BD61228F22C3605B00D3F513 /* Views */,
 			);
 			path = ResourceManager;
@@ -4716,10 +4753,10 @@
 		BD61227E22C3605B00D3F513 /* Models */ = {
 			isa = PBXGroup;
 			children = (
-				BD61227F22C3605B00D3F513 /* AliyunEffectResourceModel.m */,
 				BD61228022C3605B00D3F513 /* AliyunPage.h */,
-				BD61228122C3605B00D3F513 /* AliyunEffectResourceModel.h */,
 				BD61228222C3605B00D3F513 /* AliyunPage.m */,
+				BD61228122C3605B00D3F513 /* AliyunEffectResourceModel.h */,
+				BD61227F22C3605B00D3F513 /* AliyunEffectResourceModel.m */,
 			);
 			path = Models;
 			sourceTree = "<group>";
@@ -4727,33 +4764,26 @@
 		BD61228322C3605B00D3F513 /* Manager */ = {
 			isa = PBXGroup;
 			children = (
-				BD61228422C3605B00D3F513 /* AliyunEffectModelTransManager.m */,
-				BD61228522C3605B00D3F513 /* AliyunResourceDownloadManager.h */,
 				BD61228622C3605B00D3F513 /* AliyunDBHelper.h */,
+				BD61228B22C3605B00D3F513 /* AliyunDBHelper.m */,
 				BD61228722C3605B00D3F513 /* AliyunEffectPrestoreManager.h */,
-				BD61228822C3605B00D3F513 /* AliyunResourceRequestManager.m */,
 				BD61228922C3605B00D3F513 /* AliyunEffectPrestoreManager.m */,
+				BD61228D22C3605B00D3F513 /* AliyunResourceRequestManager.h */,
+				BD61228822C3605B00D3F513 /* AliyunResourceRequestManager.m */,
+				BD61228522C3605B00D3F513 /* AliyunResourceDownloadManager.h */,
 				BD61228A22C3605B00D3F513 /* AliyunResourceDownloadManager.m */,
-				BD61228B22C3605B00D3F513 /* AliyunDBHelper.m */,
 				BD61228C22C3605B00D3F513 /* AliyunEffectModelTransManager.h */,
-				BD61228D22C3605B00D3F513 /* AliyunResourceRequestManager.h */,
+				BD61228422C3605B00D3F513 /* AliyunEffectModelTransManager.m */,
 			);
 			path = Manager;
 			sourceTree = "<group>";
 		};
-		BD61228E22C3605B00D3F513 /* Controllers */ = {
-			isa = PBXGroup;
-			children = (
-			);
-			path = Controllers;
-			sourceTree = "<group>";
-		};
 		BD61228F22C3605B00D3F513 /* Views */ = {
 			isa = PBXGroup;
 			children = (
+				BD61229222C3605B00D3F513 /* AliyunEffectFilterCell.h */,
 				BD61229022C3605B00D3F513 /* AliyunEffectFilterCell.m */,
 				BD61229122C3605B00D3F513 /* AliyunEffectFilterCell.xib */,
-				BD61229222C3605B00D3F513 /* AliyunEffectFilterCell.h */,
 			);
 			path = Views;
 			sourceTree = "<group>";
@@ -4995,6 +5025,7 @@
 			children = (
 				BD61225022C31EED00D3F513 /* VideoRecord */,
 				BD61224F22C31EE400D3F513 /* VideoEdit */,
+				BD0FAA4B22C474A500DDFB37 /* VideoCoverPick */,
 				BD61226222C3592C00D3F513 /* Common */,
 			);
 			path = ShortVideoFile;
@@ -5584,6 +5615,7 @@
 				A70B2C60228870CE00B2449F /* ShopSectionHeaderView.swift in Sources */,
 				A7CC7528227196C4003C4F38 /* AccountSecuritySetTableViewCell.swift in Sources */,
 				A7F2D6E122B25EF30093000B /* CardContentPicVideoModel.swift in Sources */,
+				BD0FAA5622C4752C00DDFB37 /* AliyunPublishTopView.m in Sources */,
 				A70B2C292286D77200B2449F /* ProductDetailProductInfoTableViewCell.swift in Sources */,
 				A74322A922B900180017C367 /* CommunityFindFriendsViewController.swift in Sources */,
 				BD13B6E222BA03BC008BB323 /* PublishTopicTypeCell.swift in Sources */,
@@ -5654,6 +5686,7 @@
 				A72A73142232475E00B21995 /* AlipayManager.swift in Sources */,
 				A7824B042271F10300ABA381 /* EditSelfMentionContactsView.swift in Sources */,
 				A7274C5B228EE636000E3A07 /* LBXScanViewController.swift in Sources */,
+				BD0FAA5322C4750A00DDFB37 /* AliyunCoverPickView.m in Sources */,
 				BD61229422C3605C00D3F513 /* AliyunPage.m in Sources */,
 				A7FF1566228C6DF200A85748 /* OrderShopAndStatusTableViewCell.swift in Sources */,
 				A7A98E332280272A005306E9 /* ShoppingMallBannerTableViewCell.swift in Sources */,
@@ -5825,6 +5858,7 @@
 				A72A72C322321DE000B21995 /* Extension+Date.swift in Sources */,
 				A7931E0322AF827600297D0A /* ESTabBarItemBadgeView.swift in Sources */,
 				A70B2C5522885AF500B2449F /* ShareCollectionViewCell.swift in Sources */,
+				BD0FAA4F22C474D400DDFB37 /* AliyunCoverPickViewController.m in Sources */,
 				A7A98E3A2280312C005306E9 /* ShoppingMallCategoryTableViewCell.swift in Sources */,
 				BD12203622AF807C0051C7C2 /* MessagePlanetActivityController.swift in Sources */,
 				BD13B6C222BA034D008BB323 /* PublishEditAddImgCollectionCell.swift in Sources */,

+ 1 - 1
RainbowPlanet/RainbowPlanet/Macro/RainbowPlanet-Bridging-Header.h

@@ -69,7 +69,7 @@
 
 
 #import "AliyunMagicCameraViewController.h"
-
+#import "AliyunCoverPickViewController.h"
 
 
 #endif /* RainbowPlanet_Bridging_Header_h */

+ 15 - 0
RainbowPlanet/RainbowPlanet/Modules/PublishModule/AliyunVideo/AlivcShortVideo/ShortVideoFile/VideoCoverPick/Controller/AliyunCoverPickViewController.h

@@ -0,0 +1,15 @@
+//
+//  AliyunCoverPickViewController.h
+//  qusdk
+//
+//  Created by Worthy on 2017/11/7.
+//  Copyright © 2017年 Alibaba Group Holding Limited. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface AliyunCoverPickViewController : UIViewController
+@property (nonatomic, assign) CGSize outputSize;
+@property (nonatomic, strong) NSString *videoPath;
+@property (nonatomic, strong) void(^finishHandler)(UIImage *image);
+@end

+ 98 - 0
RainbowPlanet/RainbowPlanet/Modules/PublishModule/AliyunVideo/AlivcShortVideo/ShortVideoFile/VideoCoverPick/Controller/AliyunCoverPickViewController.m

@@ -0,0 +1,98 @@
+//
+//  AliyunCoverPickViewController.m
+//  qusdk
+//
+//  Created by Worthy on 2017/11/7.
+//  Copyright © 2017年 Alibaba Group Holding Limited. All rights reserved.
+//
+
+#import "AliyunCoverPickViewController.h"
+#import "AVC_ShortVideo_Config.h"
+#import "AliyunCoverPickView.h"
+#import "AliyunPublishTopView.h"
+#import "AlivcMacro.h"
+
+@interface AliyunCoverPickViewController () <AliyunPublishTopViewDelegate,
+                                             AliyunCoverPickViewDelegate>
+@property(nonatomic, strong) AliyunPublishTopView *topView;
+@property(nonatomic, strong) UIImageView *coverView;
+@property(nonatomic, strong) AliyunCoverPickView *pickView;
+
+@end
+
+@implementation AliyunCoverPickViewController
+
+- (void)viewDidLoad {
+  [super viewDidLoad];
+  [self setupSubviews];
+  dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
+                 ^{
+                   [self.pickView loadThumbnailData];
+                 });
+}
+
+- (void)setupSubviews {
+  self.topView = [[AliyunPublishTopView alloc]
+      initWithFrame:CGRectMake(0, 0, ScreenWidth, StatusBarHeight + 44)];
+  self.topView.nameLabel.text = @"编辑封面";
+  [self.topView.cancelButton setImage:[AliyunImage imageNamed:@"cancel"]
+                             forState:UIControlStateNormal];
+  [self.topView.cancelButton setTitle:nil forState:UIControlStateNormal];
+  [self.topView.finishButton setImage:[AliyunImage imageNamed:@"check"]
+                             forState:UIControlStateNormal];
+  [self.topView.finishButton setTitle:nil forState:UIControlStateNormal];
+  self.topView.delegate = self;
+  self.topView.delegate = self;
+  [self.view addSubview:self.topView];
+
+  CGFloat pickWith = ScreenWidth - 56;
+  CGFloat factor = _outputSize.height / _outputSize.width;
+  CGFloat width = ScreenWidth;
+  CGFloat heigt = ScreenWidth * factor;
+  CGFloat maxheight =
+      ScreenHeight - StatusBarHeight - 69 - SafeBottom - pickWith / 8 - 30;
+
+  if (heigt > maxheight) {
+    heigt = maxheight;
+    width = heigt / factor;
+  }
+  CGFloat offset = (maxheight - heigt) / 2;
+
+  self.coverView = [[UIImageView alloc]
+      initWithFrame:CGRectMake((ScreenWidth - width) / 2,
+                               StatusBarHeight + 44 + offset, width, heigt)];
+  [self.view addSubview:self.coverView];
+
+  self.pickView = [[AliyunCoverPickView alloc]
+      initWithFrame:CGRectMake(28,
+                               ScreenHeight - SafeBottom - pickWith / 8 - 30,
+                               pickWith, pickWith / 8)];
+  self.pickView.delegate = self;
+  self.pickView.videoPath = _videoPath;
+  self.pickView.outputSize = _outputSize;
+  [self.view addSubview:self.pickView];
+  self.view.backgroundColor = [AliyunIConfig config].backgroundColor;
+}
+
+#pragma mark - top view delegate
+
+- (void)cancelButtonClicked {
+  [self.navigationController popViewControllerAnimated:YES];
+}
+
+- (void)finishButtonClicked {
+  _finishHandler(_coverView.image);
+  [self.navigationController popViewControllerAnimated:YES];
+}
+
+#pragma mark - pick view delegate
+
+- (void)pickViewDidUpdateImage:(UIImage *)image {
+  dispatch_async(dispatch_get_main_queue(), ^{
+    _coverView.image = image;
+  });
+}
+- (BOOL)shouldAutorotate {
+  return NO;
+}
+@end

+ 20 - 0
RainbowPlanet/RainbowPlanet/Modules/PublishModule/AliyunVideo/AlivcShortVideo/ShortVideoFile/VideoCoverPick/View/AliyunCoverPickView.h

@@ -0,0 +1,20 @@
+//
+//  AliyunCoverPickView.h
+//  qusdk
+//
+//  Created by Worthy on 2017/11/7.
+//  Copyright © 2017年 Alibaba Group Holding Limited. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+@protocol AliyunCoverPickViewDelegate
+- (void)pickViewDidUpdateImage:(UIImage *)image;
+@end
+
+@interface AliyunCoverPickView : UIView
+@property (nonatomic, weak) id<AliyunCoverPickViewDelegate> delegate;
+@property (nonatomic, strong) NSString *videoPath;
+@property (nonatomic, assign) CGSize outputSize;
+@property (nonatomic, strong) UIImage *selectedImage;
+- (void)loadThumbnailData;
+@end

+ 223 - 0
RainbowPlanet/RainbowPlanet/Modules/PublishModule/AliyunVideo/AlivcShortVideo/ShortVideoFile/VideoCoverPick/View/AliyunCoverPickView.m

@@ -0,0 +1,223 @@
+//
+//  AliyunCoverPickView.m
+//  qusdk
+//
+//  Created by Worthy on 2017/11/7.
+//  Copyright © 2017年 Alibaba Group Holding Limited. All rights reserved.
+//
+
+#import "AliyunCoverPickView.h"
+#import "AVAsset+VideoInfo.h"
+#import "AVC_ShortVideo_Config.h"
+#import <AVFoundation/AVFoundation.h>
+@interface AliyunCoverPickView ()
+@property(nonatomic, strong) UICollectionView *collectionView;
+@property(nonatomic, strong) UIImageView *progressView;
+@property(nonatomic, strong) NSMutableArray *imagesArray;
+@property(nonatomic, strong) AVAssetImageGenerator *imageGenerator;
+@property(nonatomic, strong) AVAssetImageGenerator *pickGenerator;
+@property(nonatomic, assign) CGFloat duration;
+@property(nonatomic, assign) BOOL imageCaptured;
+@end
+
+@implementation AliyunCoverPickView
+
+- (instancetype)initWithFrame:(CGRect)frame {
+  self = [super initWithFrame:frame];
+  if (self) {
+    _imagesArray = [NSMutableArray arrayWithCapacity:8];
+    [self setupSubviews];
+  }
+  return self;
+}
+
+- (void)setupSubviews {
+  UICollectionViewFlowLayout *followLayout =
+      [[UICollectionViewFlowLayout alloc] init];
+  followLayout.itemSize =
+      CGSizeMake(CGRectGetHeight(self.frame), CGRectGetHeight(self.frame));
+  followLayout.minimumLineSpacing = 0;
+  followLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
+
+  _collectionView = [[UICollectionView alloc]
+             initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.frame),
+                                      CGRectGetHeight(self.frame))
+      collectionViewLayout:followLayout];
+  _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];
+}
+
+- (void)parseAsset {
+  AVURLAsset *asset =
+      [AVURLAsset assetWithURL:[NSURL fileURLWithPath:_videoPath]];
+  _duration = [asset avAssetVideoTrackDuration];
+}
+
+- (void)loadThumbnailData {
+  [self parseAsset];
+
+  _selectedImage = [self coverImageAtTime:CMTimeMake(0.1 * 1000, 1000)];
+  [_delegate pickViewDidUpdateImage:_selectedImage];
+
+  CMTime startTime = kCMTimeZero;
+  NSMutableArray *array = [NSMutableArray array];
+  CMTime addTime = CMTimeMake(_duration * 1000 / 8.0f, 1000);
+
+  CMTime endTime = CMTimeMake(_duration * 1000, 1000);
+  while (CMTIME_COMPARE_INLINE(startTime, <, endTime)) {
+    [array addObject:[NSValue valueWithCMTime:startTime]];
+    startTime = CMTimeAdd(startTime, addTime);
+  }
+  // 第一帧取第0.1s   规避有些视频并不是从第0s开始的
+  array[0] = [NSValue valueWithCMTime:CMTimeMake(0.1 * 1000, 1000)];
+
+  __block int index = 0;
+  [self.imageGenerator
+      generateCGImagesAsynchronouslyForTimes:array
+                           completionHandler:^(
+                               CMTime requestedTime, CGImageRef _Nullable image,
+                               CMTime actualTime,
+                               AVAssetImageGeneratorResult result,
+                               NSError *_Nullable error) {
+                             if (result == AVAssetImageGeneratorSucceeded) {
+                               UIImage *img =
+                                   [[UIImage alloc] initWithCGImage:image];
+                               dispatch_async(dispatch_get_main_queue(), ^{
+                                 [_imagesArray addObject:img];
+                                 NSIndexPath *indexPath =
+                                     [NSIndexPath indexPathForItem:index
+                                                         inSection:0];
+                                 [_collectionView
+                                     insertItemsAtIndexPaths:@[ indexPath ]];
+                                 index++;
+                               });
+                             }
+                           }];
+}
+
+- (NSInteger)collectionView:(UICollectionView *)collectionView
+     numberOfItemsInSection:(NSInteger)section {
+  return _imagesArray.count;
+}
+
+- (__kindof UICollectionViewCell *)collectionView:
+                                       (UICollectionView *)collectionView
+                           cellForItemAtIndexPath:(NSIndexPath *)indexPath {
+  UICollectionViewCell *cell =
+      [collectionView dequeueReusableCellWithReuseIdentifier:@"cell"
+                                                forIndexPath:indexPath];
+  UIImage *image = _imagesArray[indexPath.row];
+  UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
+  imageView.frame = cell.contentView.bounds;
+  imageView.contentMode = UIViewContentModeScaleAspectFill;
+  imageView.clipsToBounds = YES;
+  [cell.contentView addSubview:imageView];
+  return cell;
+}
+
+- (AVAssetImageGenerator *)imageGenerator {
+  if (!_imageGenerator) {
+    AVURLAsset *asset =
+        [AVURLAsset assetWithURL:[NSURL fileURLWithPath:_videoPath]];
+    _imageGenerator = [[AVAssetImageGenerator alloc] initWithAsset:asset];
+    _imageGenerator.appliesPreferredTrackTransform = YES;
+    _imageGenerator.requestedTimeToleranceBefore = kCMTimeZero;
+    _imageGenerator.requestedTimeToleranceAfter = kCMTimeZero;
+    _imageGenerator.maximumSize = CGSizeMake(100, 100);
+  }
+  return _imageGenerator;
+}
+
+- (AVAssetImageGenerator *)pickGenerator {
+  if (!_imageGenerator) {
+    AVURLAsset *asset =
+        [AVURLAsset assetWithURL:[NSURL fileURLWithPath:_videoPath]];
+    _imageGenerator = [[AVAssetImageGenerator alloc] initWithAsset:asset];
+    _imageGenerator.appliesPreferredTrackTransform = YES;
+    _imageGenerator.requestedTimeToleranceBefore = kCMTimeZero;
+    _imageGenerator.requestedTimeToleranceAfter = kCMTimeZero;
+    _imageGenerator.maximumSize = _outputSize;
+  }
+  return _imageGenerator;
+}
+
+- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
+  UITouch *touch = (UITouch *)[touches anyObject];
+  CGPoint point = [touch locationInView:self.collectionView];
+  CGFloat percent = point.x / CGRectGetWidth(self.frame);
+  if (percent < 0) {
+    percent = 0;
+  } else if (percent > 1) {
+    percent = 1;
+  }
+  CMTime time = CMTimeMake(percent * _duration * 1000, 1000);
+  dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
+                 ^{
+                   _selectedImage = [self coverImageAtTime:time];
+                   [_delegate pickViewDidUpdateImage:_selectedImage];
+                   _imageCaptured = YES;
+                 });
+  self.progressView.center = CGPointMake(CGRectGetWidth(self.frame) * percent,
+                                         CGRectGetHeight(self.frame) / 2);
+}
+
+- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
+  UITouch *touch = (UITouch *)[touches anyObject];
+  CGPoint point = [touch locationInView:self.collectionView];
+  CGFloat percent = point.x / CGRectGetWidth(self.frame);
+  if (percent < 0) {
+    percent = 0;
+  } else if (percent > 1) {
+    percent = 1;
+  }
+  CMTime time = CMTimeMake(percent * _duration * 1000, 1000);
+  if (_imageCaptured) {
+    _imageCaptured = NO;
+    dispatch_async(
+        dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+          _selectedImage = [self coverImageAtTime:time];
+          [_delegate pickViewDidUpdateImage:_selectedImage];
+          _imageCaptured = YES;
+        });
+  }
+  self.progressView.center = CGPointMake(CGRectGetWidth(self.frame) * percent,
+                                         CGRectGetHeight(self.frame) / 2);
+}
+
+- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
+  UITouch *touch = (UITouch *)[touches anyObject];
+  CGPoint point = [touch locationInView:self.collectionView];
+  CGFloat percent = point.x / CGRectGetWidth(self.frame);
+  if (percent < 0) {
+    percent = 0;
+  } else if (percent > 1) {
+    percent = 1;
+  }
+  CMTime time = CMTimeMake(percent * _duration * 1000, 1000);
+  dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
+                 ^{
+                   _selectedImage = [self coverImageAtTime:time];
+                   [_delegate pickViewDidUpdateImage:_selectedImage];
+                 });
+  self.progressView.center = CGPointMake(CGRectGetWidth(self.frame) * percent,
+                                         CGRectGetHeight(self.frame) / 2);
+}
+
+- (UIImage *)coverImageAtTime:(CMTime)time {
+  CGImageRef image = [self.pickGenerator copyCGImageAtTime:time
+                                                actualTime:NULL
+                                                     error:nil];
+  UIImage *picture = [UIImage imageWithCGImage:image];
+  CGImageRelease(image);
+  return picture;
+}
+@end

+ 19 - 0
RainbowPlanet/RainbowPlanet/Modules/PublishModule/AliyunVideo/AlivcShortVideo/ShortVideoFile/VideoCoverPick/View/AliyunPublishTopView.h

@@ -0,0 +1,19 @@
+//
+//  AliyunPublishTopView.h
+//  qusdk
+//
+//  Created by Worthy on 2017/11/7.
+//  Copyright © 2017年 Alibaba Group Holding Limited. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+@protocol AliyunPublishTopViewDelegate <NSObject>
+-(void)cancelButtonClicked;
+-(void)finishButtonClicked;
+@end
+@interface AliyunPublishTopView : UIView
+@property (nonatomic, weak) id<AliyunPublishTopViewDelegate> delegate;
+@property (nonatomic, strong) UILabel *nameLabel;
+@property (nonatomic, strong) UIButton *cancelButton;
+@property (nonatomic, strong) UIButton *finishButton;
+@end

+ 86 - 0
RainbowPlanet/RainbowPlanet/Modules/PublishModule/AliyunVideo/AlivcShortVideo/ShortVideoFile/VideoCoverPick/View/AliyunPublishTopView.m

@@ -0,0 +1,86 @@
+//
+//  AliyunPublishTopView.m
+//  qusdk
+//
+//  Created by Worthy on 2017/11/7.
+//  Copyright © 2017年 Alibaba Group Holding Limited. All rights reserved.
+//
+
+#import "AliyunPublishTopView.h"
+#import "AVC_ShortVideo_Config.h"
+#import "AlivcMacro.h"
+
+@implementation AliyunPublishTopView
+
+- (instancetype)initWithFrame:(CGRect)frame {
+  self = [super initWithFrame:frame];
+  if (self) {
+    [self setupTopViews];
+  }
+  return self;
+}
+
+- (instancetype)initWithCoder:(NSCoder *)aDecoder {
+  self = [super initWithCoder:aDecoder];
+  if (self) {
+    [self setupTopViews];
+  }
+  return self;
+}
+
+- (void)setupTopViews {
+
+  UIView *topView = [[UIView alloc] init];
+  topView.frame = CGRectMake(0, 0, ScreenWidth, self.frame.size.height);
+  topView.backgroundColor = [AliyunIConfig config].backgroundColor;
+  ;
+  [self addSubview:topView];
+
+  UIButton *backButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
+  backButton.frame = CGRectMake(4, StatusBarHeight, 44, 44);
+  [backButton setTitle:NSLocalizedString(@"cancel_camera_import", nil)
+              forState:(UIControlStateNormal)];
+  [backButton setTitleColor:[UIColor whiteColor]
+                   forState:(UIControlStateNormal)];
+  backButton.titleLabel.font = [UIFont systemFontOfSize:14.f];
+  backButton.titleLabel.textAlignment = NSTextAlignmentCenter;
+  [backButton addTarget:self
+                 action:@selector(backButtonAction)
+       forControlEvents:(UIControlEventTouchUpInside)];
+  self.cancelButton = backButton;
+  [topView addSubview:backButton];
+
+  self.nameLabel = [[UILabel alloc] init];
+  self.nameLabel.frame =
+      CGRectMake((ScreenWidth - 68) / 2, StatusBarHeight, 68, 44);
+  self.nameLabel.font = [UIFont systemFontOfSize:14.f];
+  self.nameLabel.textColor = [UIColor whiteColor];
+  self.nameLabel.textAlignment = NSTextAlignmentCenter;
+  self.nameLabel.text = @"我的视频";
+  [topView addSubview:self.nameLabel];
+
+  UIButton *nextButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
+  nextButton.frame = CGRectMake(ScreenWidth - 44 - 4, StatusBarHeight, 44, 44);
+  [nextButton setTitle:NSLocalizedString(@"finish_subtitle_edit", nil)
+              forState:(UIControlStateNormal)];
+  [nextButton setTitleColor:[UIColor whiteColor]
+                   forState:(UIControlStateNormal)];
+  [nextButton setTitleColor:rgba(110, 118, 139, 1)
+                   forState:(UIControlStateDisabled)];
+  nextButton.titleLabel.font = [UIFont systemFontOfSize:14.f];
+  nextButton.titleLabel.textAlignment = NSTextAlignmentCenter;
+  [nextButton addTarget:self
+                 action:@selector(nextButtonAction)
+       forControlEvents:(UIControlEventTouchUpInside)];
+  self.finishButton = nextButton;
+  [topView addSubview:nextButton];
+}
+
+- (void)backButtonAction {
+  [self.delegate cancelButtonClicked];
+}
+
+- (void)nextButtonAction {
+  [self.delegate finishButtonClicked];
+}
+@end

+ 3 - 16
RainbowPlanet/RainbowPlanet/Modules/PublishModule/AliyunVideo/AlivcShortVideo/ShortVideoFile/VideoEdit/Controller/AliyunEditViewController.m

@@ -619,22 +619,9 @@ AliyunIExporterCallback, AliyunIPlayerCallback, AliyunMusicPickViewControllerDel
     }
     [self.player stop];
     [self.editor stopEdit];
-    AlivcOutputProductType productType = kAlivcProductType;
-    if (productType == AlivcOutputProductTypeSmartVideo) {
-        
-        // FIXME: 选择发布页面
-//        Class AlivcPublishQuViewControl = NSClassFromString(@"AlivcPublishQuViewControl");
-//        UIViewController *targetVC = [[AlivcPublishQuViewControl alloc]init];
-//        if (!self.coverImage) {
-//            self.coverImage = [self featchFirstFrame];
-//        }
-//        [targetVC setValue:self.coverImage forKey:@"coverImage"];
-//        [targetVC setValue:_taskPath forKey:@"taskPath"];
-//        [targetVC setValue:_config forKey:@"config"];
-//        [self.navigationController pushViewController:targetVC animated:YES];
-    } else {
-        
-    }
+    
+    NSDictionary *coverDic = @{@"outputSize":@(_outputSize), @"videoPath":_config.outputPath};
+    [[NSNotificationCenter defaultCenter] postNotificationName: @"PushNotificationEditToCover" object: coverDic];
 }
 
 #pragma mark - Notification

+ 30 - 0
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishViewController.swift

@@ -11,6 +11,11 @@ import JXSegmentedView
 
 class PublishViewController: BaseViewController {
     
+    weak var observe : NSObjectProtocol?
+    deinit {
+        NotificationCenter.default.removeObserver(observe as Any)
+    }
+    
     // 视频选择页参数配置类
     var mediaConfig: AliyunMediaConfig {
         //默认配置
@@ -30,6 +35,31 @@ class PublishViewController: BaseViewController {
         setupViews()
         setupLayouts()
         setupData()
+        
+        let operationQueue = OperationQueue.main
+        observe = NotificationCenter.default.addObserver(forName: NSNotification.Name(rawValue: "PushNotificationEditToCover"), object: nil, queue: operationQueue) {
+            [weak self] (notification) in
+            let paraDic = notification.object as! Dictionary<String, Any>
+            let coverVc = AliyunCoverPickViewController()
+            coverVc.outputSize = paraDic["outputSize"] as! CGSize
+            coverVc.videoPath = paraDic["videoPath"] as? String
+            coverVc.finishHandler = {
+                [weak self] (image) in
+                print("----image:\n\(image)")
+            }
+            
+            self?.navigationController?.pushViewController(coverVc, animated: true)
+            
+//            AliyunCoverPickViewController *vc = [AliyunCoverPickViewController new];
+//            vc.outputSize = _outputSize;
+//            vc.videoPath = _config.outputPath;
+//            vc.finishHandler = ^(UIImage *image) {
+//                _image = image;
+//                _coverImageView.image = image;
+//                _backgroundView.image = image;
+//            };
+//            [self.navigationController pushViewController:vc animated:YES];
+        }
     }
     
     override func setupViews() {