|
@@ -14,6 +14,7 @@
|
|
|
#import "KSMediaManager.h"
|
|
|
#import "StyleVideoModel.h"
|
|
|
#import "WMPlayer.h"
|
|
|
+#import "KSVideoHelper.h"
|
|
|
|
|
|
@interface MyStyleViewController ()<UITableViewDelegate,UITableViewDataSource,WMPlayerDelegate>
|
|
|
{
|
|
@@ -28,6 +29,8 @@
|
|
|
|
|
|
@property (nonatomic, strong) NSMutableArray *videoArray;
|
|
|
|
|
|
+@property (nonatomic, strong) NSMutableArray *videoPageArray;
|
|
|
+
|
|
|
@property (nonatomic, strong) NSString *content;
|
|
|
|
|
|
@property (nonatomic, strong) UITableView *tableView;
|
|
@@ -132,9 +135,11 @@
|
|
|
NSMutableDictionary *parm = [NSMutableDictionary dictionary];
|
|
|
if (model.isChooseVideo) {
|
|
|
[parm setValue:model.videoUrl forKey:@"videoUrl"];
|
|
|
+ [parm setValue:model.cover forKey:@"cover"];
|
|
|
}
|
|
|
else {
|
|
|
[parm setValue:model.internalBaseClassIdentifier forKey:@"id"];
|
|
|
+ [parm setValue:model.cover forKey:@"cover"];
|
|
|
[parm setValue:model.videoUrl forKey:@"videoUrl"];
|
|
|
}
|
|
|
[videoArray addObject:parm];
|
|
@@ -209,8 +214,10 @@
|
|
|
MJWeakSelf;
|
|
|
[self.mediaManager noAlertCallback:^(NSString * _Nullable videoUrl, NSMutableArray * _Nullable imageArray, NSMutableArray * _Nullable imageAsset) {
|
|
|
NSLog(@"%@", videoUrl);
|
|
|
- // 上传视频
|
|
|
- [weakSelf uploadVideoWithUrl:videoUrl];
|
|
|
+ // 先选择首帧图
|
|
|
+ [weakSelf uploadUrlAndGetImagePath:videoUrl];
|
|
|
+// // 上传视频
|
|
|
+// [weakSelf uploadVideoWithUrl:videoUrl];
|
|
|
}];
|
|
|
[self.mediaManager pushImagePickerController];
|
|
|
}
|
|
@@ -239,8 +246,34 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+- (void)uploadUrlAndGetImagePath:(NSString *)videoUrl {
|
|
|
+ [KSVideoHelper getLocalVideoPreViewUrlWithPath:videoUrl callback:^(UIImage * _Nullable firstImage) {
|
|
|
+ if (firstImage) {
|
|
|
+ // 上传图片
|
|
|
+ NSData *imgData = [UIImage compressImage:firstImage maxLength:5];
|
|
|
+ NSString *fileName = @"whiteboardImage";
|
|
|
+ [[KSUploadManager shareInstance] configBucketName:@"daya"];
|
|
|
+ [[KSUploadManager shareInstance] uploadImage:imgData fileName:fileName successCallback:^(NSMutableArray * _Nonnull fileUrlArray) {
|
|
|
+ NSString *imageUrl = [fileUrlArray lastObject];
|
|
|
+ [self uploadVideoWithUrl:videoUrl coverUrl:imageUrl];
|
|
|
+
|
|
|
+ } faliure:^(NSError * _Nullable error, NSString * _Nullable descMessaeg) {
|
|
|
+ if ([NSString isEmptyString:descMessaeg]) {
|
|
|
+ [self MBPShow:descMessaeg];
|
|
|
+ }
|
|
|
+ }];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ // 如果没有直接上传图片
|
|
|
+ [self uploadVideoWithUrl:videoUrl coverUrl:nil];
|
|
|
+ }
|
|
|
+
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
#pragma mark --- 上传视频文件
|
|
|
-- (void)uploadVideoWithUrl:(NSString *)videoUrl {
|
|
|
+- (void)uploadVideoWithUrl:(NSString *)videoUrl coverUrl:(NSString *)coverUrl {
|
|
|
[self hudTipWillShow:YES];
|
|
|
NSURL *fileUrl = [NSURL fileURLWithPath:videoUrl];
|
|
|
NSData *fileData = [NSData dataWithContentsOfURL:fileUrl];
|
|
@@ -261,6 +294,7 @@
|
|
|
StyleVideoModel *model = [[StyleVideoModel alloc] init];
|
|
|
model.videoUrl = fileUrl;
|
|
|
model.isChooseVideo = YES;
|
|
|
+ model.cover = coverUrl;
|
|
|
[self.videoArray addObject:model];
|
|
|
[self.tableView reloadData];
|
|
|
} faliure:^(NSError * _Nullable error, NSString * _Nullable descMessaeg) {
|
|
@@ -380,6 +414,13 @@
|
|
|
return _videoArray;
|
|
|
}
|
|
|
|
|
|
+- (NSMutableArray *)videoPageArray {
|
|
|
+ if (!_videoPageArray) {
|
|
|
+ _videoPageArray = [NSMutableArray array];
|
|
|
+ }
|
|
|
+ return _videoPageArray;
|
|
|
+}
|
|
|
+
|
|
|
- (void)hudTipWillShow:(BOOL)willShow{
|
|
|
if (willShow) {
|
|
|
[self resignFirstResponder];
|