|
@@ -17,7 +17,6 @@
|
|
|
#import <AliyunVideoSDKPro/AliyunClipManager.h>
|
|
|
#import <AliyunVideoSDKPro/AliyunHttpClient.h>
|
|
|
#import <CoreMotion/CoreMotion.h>
|
|
|
-#import "AliyunMusicPickViewController.h"
|
|
|
#import "AliyunPathManager.h"
|
|
|
#import "MBProgressHUD.h"
|
|
|
#import "AliyunEffectResourceModel.h"
|
|
@@ -42,7 +41,7 @@
|
|
|
#import "RainbowPlanet-Swift.h"
|
|
|
|
|
|
|
|
|
-@interface AliyunMagicCameraViewController () <AliyunMusicPickViewControllerDelegate, UIGestureRecognizerDelegate, UIAlertViewDelegate, AliyunIRecorderDelegate, AliyunEffectFilter2ViewDelegate>
|
|
|
+@interface AliyunMagicCameraViewController () <UIGestureRecognizerDelegate, UIAlertViewDelegate, AliyunIRecorderDelegate, AliyunEffectFilter2ViewDelegate>
|
|
|
{
|
|
|
NSURLSessionDownloadTask *_downloadTask;
|
|
|
}
|
|
@@ -97,8 +96,7 @@
|
|
|
@property (nonatomic, strong) AlivcPushBeautyDataManager *beautyFaceDataManager_normal; //普通美颜的数据管理器
|
|
|
@property (nonatomic, strong) AlivcPushBeautyDataManager *beautyFaceDataManager_advanced; //高级美颜的数据管理器
|
|
|
@property (nonatomic, strong) AlivcPushBeautyDataManager *beautySkinDataManager; //美肌的数据管理器
|
|
|
-@property (nonatomic, strong) AliyunMusicPickModel *music; //之前应用的音乐
|
|
|
-@property (nonatomic, assign) NSInteger tab; //之前应用的音乐的所属0远程 1本地
|
|
|
+@property (nonatomic, strong) NSString *curMusicUrl; //之前应用的音乐のUrl
|
|
|
@property (nonatomic, strong) AliyunReachability *reachability; //网络监听
|
|
|
@property (nonatomic, strong) AliyunDBHelper *dbHelper; //数据库
|
|
|
|
|
@@ -217,8 +215,9 @@
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
|
[super viewDidLoad];
|
|
|
- _cameraRotate =90;
|
|
|
- _needStopPreview =YES;
|
|
|
+ _cameraRotate = 90;
|
|
|
+ _needStopPreview = YES;
|
|
|
+ _curMusicUrl = @"";
|
|
|
|
|
|
Class c = NSClassFromString(@"AliyunEffectPrestoreManager");
|
|
|
NSObject *prestore = (NSObject *)[[c alloc] init];
|
|
@@ -447,15 +446,23 @@
|
|
|
{
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillResignActive:) name:UIApplicationWillResignActiveNotification object:nil];
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appDidBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:nil];
|
|
|
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(resourceDelete:) name:AliyunEffectResourceDeleteNotification object:nil];
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(musicViewDidClose) name:@"RecordCloseMusicChooseViewNoti" object:nil];
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadMusicAndCombineNoti:) name:@"RecordDownloadMusicAndCombineNoti" object:nil];
|
|
|
}
|
|
|
|
|
|
- (void)downloadMusicAndCombineNoti:(NSNotification *)noti {
|
|
|
NSString *urlStr = noti.object;
|
|
|
- NSLog(@"\n------receiveNoti.urlStr == %@", urlStr);
|
|
|
- [self downloadFileFromServerWithUrlStr:urlStr];
|
|
|
+ self.curMusicUrl = urlStr;
|
|
|
+
|
|
|
+ if ([urlStr isEqualToString:@""]) {
|
|
|
+ // 不选择音乐(清除音乐效果)
|
|
|
+ [_recorder applyMusic:nil];
|
|
|
+ } else {
|
|
|
+ [self downloadFileFromServerWithUrlStr:urlStr];
|
|
|
+ }
|
|
|
+
|
|
|
+ // 音乐按钮动效设置
|
|
|
+ [self changeMusicButtonStatus];
|
|
|
}
|
|
|
|
|
|
- (void)musicViewDidClose {
|
|
@@ -469,16 +476,6 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- 资源被删除的通知
|
|
|
-
|
|
|
- @param noti 通知对象
|
|
|
- */
|
|
|
-- (void)resourceDelete:(NSNotification *)noti{
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
- (void)appWillResignActive:(id)sender
|
|
|
{
|
|
|
if ([self.navigationController.childViewControllers lastObject] != self) {
|
|
@@ -605,12 +602,10 @@
|
|
|
NSString *musicFilePath = [filePath path];// 将NSURL转成NSString
|
|
|
NSLog(@"\n------下载音乐成功!path == %@", musicFilePath);
|
|
|
|
|
|
-
|
|
|
- // FIXME: to be fixed
|
|
|
+ // 应用音乐效果
|
|
|
AVURLAsset *asset = [AVURLAsset assetWithURL:[NSURL fileURLWithPath:musicFilePath]];
|
|
|
CGFloat musicDuration = [asset avAssetVideoTrackDuration];
|
|
|
|
|
|
-
|
|
|
AliyunEffectMusic *effectMusic = [[AliyunEffectMusic alloc] initWithFile:musicFilePath];
|
|
|
effectMusic.startTime = 0;
|
|
|
effectMusic.duration = musicDuration;
|
|
@@ -656,6 +651,9 @@
|
|
|
[super viewWillAppear:animated];
|
|
|
|
|
|
_magicCameraView.musicButton.enabled = ![_clipManager partCount];
|
|
|
+ // 音乐按钮动效设置
|
|
|
+ [self changeMusicButtonStatus];
|
|
|
+
|
|
|
NSLog(@"%zd",[_clipManager partCount]);
|
|
|
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];//录制模块禁止自动熄屏
|
|
|
[self startRetainCameraRotate];
|
|
@@ -837,15 +835,7 @@
|
|
|
|
|
|
- (void)musicButtonClicked
|
|
|
{
|
|
|
-// AliyunMusicPickViewController *vc =[[AliyunMusicPickViewController alloc] init];
|
|
|
-// vc.delegate = self;
|
|
|
-// vc.duration = _clipManager.maxDuration;
|
|
|
-// vc.selectedMusic = self.music;
|
|
|
-// vc.selectedTab = self.tab;
|
|
|
-// self.needStopPreview =NO;
|
|
|
-// [self.navigationController pushViewController:vc animated:YES];
|
|
|
-
|
|
|
- self.musicView = [PublishRecordMusicView publishRecordMusicViewWithAttachedView:self.view];
|
|
|
+ self.musicView = [PublishRecordMusicView publishRecordMusicViewWithAttachedView:self.view curMusicUrl:self.curMusicUrl];
|
|
|
if (self.hideSegmentBlock) {
|
|
|
self.hideSegmentBlock(true);
|
|
|
self.magicCameraView.rateView.hidden = true;
|
|
@@ -957,28 +947,23 @@
|
|
|
[self.recorder setRate:rate];
|
|
|
}
|
|
|
|
|
|
-#pragma mark - AliyunMusicPickViewControllerDelegate
|
|
|
-
|
|
|
--(void)didSelectMusic:(AliyunMusicPickModel *)music tab:(NSInteger)tab{
|
|
|
- self.music = music;
|
|
|
- self.tab = tab;
|
|
|
-
|
|
|
- if ([music.name isEqualToString:@"无音乐"] || !music.path || ![[NSFileManager defaultManager] fileExistsAtPath:music.path]) {
|
|
|
- //清除音乐效果
|
|
|
- [_recorder applyMusic:nil];
|
|
|
- self.tab =0;
|
|
|
+// 改变音乐Btn的图片状态及动画效果
|
|
|
+- (void)changeMusicButtonStatus {
|
|
|
+ if(self.curMusicUrl && ![self.curMusicUrl isEqualToString:@""]){
|
|
|
+ // 添加动效
|
|
|
+ [_magicCameraView.musicButton setImage:[UIImage imageNamed:@"video_ico_music_pre"] forState:UIControlStateNormal];
|
|
|
+
|
|
|
+ CABasicAnimation *rotateAnimate = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
|
|
|
+ rotateAnimate.fromValue = @(0);
|
|
|
+ rotateAnimate.toValue = @(M_PI * 2);
|
|
|
+ rotateAnimate.repeatCount = NSIntegerMax;
|
|
|
+ rotateAnimate.duration = 35;
|
|
|
+ [_magicCameraView.musicButton.imageView.layer addAnimation:rotateAnimate forKey:nil];
|
|
|
+
|
|
|
}else{
|
|
|
- AliyunEffectMusic *effectMusic = [[AliyunEffectMusic alloc] initWithFile:music.path];
|
|
|
- effectMusic.startTime = music.startTime;
|
|
|
- effectMusic.duration = music.duration;
|
|
|
- [_recorder applyMusic:effectMusic];
|
|
|
- NSLog(@"%@",effectMusic.path);
|
|
|
- NSLog(@"----------->:有path,有文件");
|
|
|
+ [_magicCameraView.musicButton setImage:_uiConfig.musicImage forState:UIControlStateNormal];
|
|
|
+ [_magicCameraView.musicButton.imageView.layer removeAllAnimations];
|
|
|
}
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
--(void)didCancelPick {
|
|
|
}
|
|
|
|
|
|
#pragma mark - AliyunIRecorderDelegate -
|
|
@@ -1082,7 +1067,7 @@
|
|
|
}else{
|
|
|
[[AlivcShortVideoRoute shared]registerEditVideoPath:outputPath];
|
|
|
[[AlivcShortVideoRoute shared]registerEditMediasPath:nil];
|
|
|
- if(self.music && ![self.music.name isEqualToString:@"无音乐"]){
|
|
|
+ if(self.curMusicUrl && ![self.curMusicUrl isEqualToString:@""]){
|
|
|
[[AlivcShortVideoRoute shared] registerHasRecordMusic:YES];
|
|
|
}else{
|
|
|
[[AlivcShortVideoRoute shared] registerHasRecordMusic:NO];
|