|
@@ -106,8 +106,8 @@ AliyunIExporterCallback, AliyunIPlayerCallback>
|
|
// 配乐のView
|
|
// 配乐のView
|
|
@property (nonatomic, strong) PublishMusicChooseView *musicView;
|
|
@property (nonatomic, strong) PublishMusicChooseView *musicView;
|
|
|
|
|
|
-@property (nonatomic, assign) CGFloat originAudioVolumn;
|
|
|
|
-@property (nonatomic, assign) CGFloat backAudioVolumn;
|
|
|
|
|
|
+@property (nonatomic, assign) int originAudioVolumn;
|
|
|
|
+@property (nonatomic, assign) int backAudioVolumn;
|
|
|
|
|
|
/**
|
|
/**
|
|
当前控制器是否可见
|
|
当前控制器是否可见
|
|
@@ -192,15 +192,14 @@ AliyunIExporterCallback, AliyunIPlayerCallback>
|
|
AliyunClip *clip = [[AliyunClip alloc] initWithVideoPath:_videoPath animDuration:0];
|
|
AliyunClip *clip = [[AliyunClip alloc] initWithVideoPath:_videoPath animDuration:0];
|
|
[importer addMediaClip:clip];
|
|
[importer addMediaClip:clip];
|
|
[importer generateProjectConfigure];
|
|
[importer generateProjectConfigure];
|
|
- NSLog(@"---------->clip.duration:%f",clip.duration);
|
|
|
|
_config.outputPath = [[_taskPath stringByAppendingPathComponent:[AliyunPathManager randomString]] stringByAppendingPathExtension:@"mp4"];
|
|
_config.outputPath = [[_taskPath stringByAppendingPathComponent:[AliyunPathManager randomString]] stringByAppendingPathExtension:@"mp4"];
|
|
}
|
|
}
|
|
_tryResumeWhenBack = NO;
|
|
_tryResumeWhenBack = NO;
|
|
|
|
|
|
//防size异常奔溃处理
|
|
//防size异常奔溃处理
|
|
if (_outputSize.height == 0 || _outputSize.width == 0) {
|
|
if (_outputSize.height == 0 || _outputSize.width == 0) {
|
|
- _outputSize.width = 720;
|
|
|
|
- _outputSize.height = 1280;
|
|
|
|
|
|
+ _outputSize.width = 540;
|
|
|
|
+ _outputSize.height = 960;
|
|
NSAssert(false, @"调试的时候崩溃,_outputSize分辨率异常处理");
|
|
NSAssert(false, @"调试的时候崩溃,_outputSize分辨率异常处理");
|
|
}
|
|
}
|
|
//默认的ui配置
|
|
//默认的ui配置
|
|
@@ -362,7 +361,6 @@ AliyunIExporterCallback, AliyunIPlayerCallback>
|
|
- (void)viewWillAppear:(BOOL)animated {
|
|
- (void)viewWillAppear:(BOOL)animated {
|
|
[super viewWillAppear:animated];
|
|
[super viewWillAppear:animated];
|
|
self.isAppear = YES;
|
|
self.isAppear = YES;
|
|
- [[UIApplication sharedApplication] setStatusBarHidden:YES];
|
|
|
|
if (_tryResumeWhenBack) {
|
|
if (_tryResumeWhenBack) {
|
|
if (!_prePlaying) {
|
|
if (!_prePlaying) {
|
|
[self resume];
|
|
[self resume];
|
|
@@ -392,7 +390,6 @@ AliyunIExporterCallback, AliyunIPlayerCallback>
|
|
respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
|
|
respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
|
|
self.navigationController.interactivePopGestureRecognizer.enabled = YES;
|
|
self.navigationController.interactivePopGestureRecognizer.enabled = YES;
|
|
};
|
|
};
|
|
- [[UIApplication sharedApplication] setStatusBarHidden:NO];
|
|
|
|
//停止编辑
|
|
//停止编辑
|
|
[self.editor stopEdit];
|
|
[self.editor stopEdit];
|
|
}
|
|
}
|
|
@@ -654,12 +651,16 @@ AliyunIExporterCallback, AliyunIPlayerCallback>
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadMusicAndCombineNoti:) name:@"DownloadMusicAndCombineNoti" object:nil];
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadMusicAndCombineNoti:) name:@"DownloadMusicAndCombineNoti" object:nil];
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeAudioVolumn:) name:@"ChangeAudioVolumnNoti" object:nil];
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeAudioVolumn:) name:@"ChangeAudioVolumnNoti" object:nil];
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(musicViewDidClose:) name:@"EditCloseMusicChooseViewNoti" object:nil];
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(musicViewDidClose:) name:@"EditCloseMusicChooseViewNoti" object:nil];
|
|
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(volumnDidClose) name:@"EditCloseChooseVolumnNoti" object:nil];
|
|
|
|
|
|
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(volumnDidClose:) name:@"EditCloseChooseVolumnNoti" object:nil];
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-- (void)volumnDidClose {
|
|
|
|
- [self hiddenButtonisHidden:false];
|
|
|
|
|
|
+- (void)volumnDidClose:(NSNotification *)noti {
|
|
|
|
+ if ([noti.object isEqual: @"1"]) {
|
|
|
|
+ [self hiddenButtonisHidden:false];
|
|
|
|
+ }else {
|
|
|
|
+ [self musicButtonClicked];
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
- (void)removeNotifications {
|
|
- (void)removeNotifications {
|
|
@@ -691,11 +692,11 @@ AliyunIExporterCallback, AliyunIPlayerCallback>
|
|
|
|
|
|
- (void)changeAudioVolumn:(NSNotification *)noti {
|
|
- (void)changeAudioVolumn:(NSNotification *)noti {
|
|
NSDictionary *paraDic = noti.object;
|
|
NSDictionary *paraDic = noti.object;
|
|
- self.originAudioVolumn = [paraDic[@"origin"] floatValue];
|
|
|
|
- self.backAudioVolumn = [paraDic[@"back"] floatValue];
|
|
|
|
-
|
|
|
|
- [self.editor setMainStreamsAudioWeight:_originAudioVolumn];
|
|
|
|
- [self.editor setAudioWeight:_backAudioVolumn streamId:_curEffectVid];
|
|
|
|
|
|
+ self.originAudioVolumn = [paraDic[@"origin"] intValue];
|
|
|
|
+ self.backAudioVolumn = [paraDic[@"back"] intValue];
|
|
|
|
+
|
|
|
|
+ [self.editor setAudioWeight:self.backAudioVolumn streamId:self.curEffectVid];
|
|
|
|
+ [self.editor setMainStreamsAudioWeight:self.originAudioVolumn];
|
|
[self hiddenButtonisHidden:false];
|
|
[self hiddenButtonisHidden:false];
|
|
}
|
|
}
|
|
|
|
|
|
@@ -782,26 +783,28 @@ AliyunIExporterCallback, AliyunIPlayerCallback>
|
|
|
|
|
|
} completionHandler:^(NSURLResponse * _Nonnull response, NSURL * _Nullable filePath, NSError * _Nullable error) {
|
|
} completionHandler:^(NSURLResponse * _Nonnull response, NSURL * _Nullable filePath, NSError * _Nullable error) {
|
|
// filePath就是你下载文件的位置,你可以解压,也可以直接拿来使用
|
|
// filePath就是你下载文件的位置,你可以解压,也可以直接拿来使用
|
|
-
|
|
|
|
|
|
+
|
|
NSString *musicFilePath = [filePath path];// 将NSURL转成NSString
|
|
NSString *musicFilePath = [filePath path];// 将NSURL转成NSString
|
|
- NSLog(@"\n------下载音乐成功!path == %@", musicFilePath);
|
|
|
|
|
|
|
|
-
|
|
|
|
- AVURLAsset *asset = [AVURLAsset assetWithURL:[NSURL fileURLWithPath:musicFilePath]];
|
|
|
|
- CGFloat musicDuration = [asset avAssetVideoTrackDuration];
|
|
|
|
-
|
|
|
|
- //如果录制的时候有音乐 编辑的时候重新音乐 则播放新的音乐
|
|
|
|
- if (self.hasRecordMusic) {
|
|
|
|
- [self.editor setAudioMixWeight:100];
|
|
|
|
|
|
+ if (musicFilePath == nil) {
|
|
|
|
+ [[SwiftProgressHUD shared] showText:@"音乐加载失败" textAlignment:(NSTextAlignmentLeft)];
|
|
|
|
+ }else {
|
|
|
|
+ AVURLAsset *asset = [AVURLAsset assetWithURL:[NSURL fileURLWithPath:musicFilePath]];
|
|
|
|
+ CGFloat musicDuration = [asset avAssetVideoTrackDuration];
|
|
|
|
+
|
|
|
|
+ //如果录制的时候有音乐 编辑的时候重新音乐 则播放新的音乐
|
|
|
|
+ if (self.hasRecordMusic) {
|
|
|
|
+ [self.editor setAudioMixWeight:100];
|
|
|
|
+ }
|
|
|
|
+ [self.editor removeMusics];
|
|
|
|
+ AliyunEffectMusic *effectMusic =[[AliyunEffectMusic alloc] initWithFile:musicFilePath];
|
|
|
|
+ effectMusic.startTime = 0;
|
|
|
|
+ effectMusic.duration = musicDuration;
|
|
|
|
+ [self.editor applyMusic:effectMusic];
|
|
|
|
+ self.curEffectVid = [effectMusic effectVid];
|
|
|
|
+
|
|
|
|
+ [self resume];
|
|
}
|
|
}
|
|
- [self.editor removeMusics];
|
|
|
|
- AliyunEffectMusic *effectMusic =[[AliyunEffectMusic alloc] initWithFile:musicFilePath];
|
|
|
|
- effectMusic.startTime = 0;
|
|
|
|
- effectMusic.duration = musicDuration;
|
|
|
|
- self.curEffectVid = [effectMusic effectVid];
|
|
|
|
- [self.editor applyMusic:effectMusic];
|
|
|
|
-
|
|
|
|
- [self resume];
|
|
|
|
}];
|
|
}];
|
|
|
|
|
|
// 开始执行下载
|
|
// 开始执行下载
|