Browse Source

功能优化

Steven 7 months ago
parent
commit
1d63ed27c0

+ 6 - 0
KulexiuForTeacher/KulexiuForTeacher.xcodeproj/project.pbxproj

@@ -536,6 +536,7 @@
 		BC42CAB02BEC9CDA001F076E /* RhythmView.m in Sources */ = {isa = PBXBuildFile; fileRef = BC42CAAC2BEC9CDA001F076E /* RhythmView.m */; };
 		BC42CAB12BEC9CDA001F076E /* RhythmView.xib in Resources */ = {isa = PBXBuildFile; fileRef = BC42CAAD2BEC9CDA001F076E /* RhythmView.xib */; };
 		BC4823D12C4F5F30000E5401 /* UserDetailModel.m in Sources */ = {isa = PBXBuildFile; fileRef = BC4823D02C4F5F30000E5401 /* UserDetailModel.m */; };
+		BC4823D42C4F8FC0000E5401 /* KSAccompanyDraftViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BC4823D22C4F8FBF000E5401 /* KSAccompanyDraftViewController.m */; };
 		BC483231282A646A005F534C /* HomeRecentCourseView.m in Sources */ = {isa = PBXBuildFile; fileRef = BC483230282A646A005F534C /* HomeRecentCourseView.m */; };
 		BC483233282A6473005F534C /* HomeRecentCourseView.xib in Resources */ = {isa = PBXBuildFile; fileRef = BC483232282A6473005F534C /* HomeRecentCourseView.xib */; };
 		BC48C3AE28292FB600EE65C5 /* ReceiveHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = BC48C3AD28292FB600EE65C5 /* ReceiveHeaderView.m */; };
@@ -2038,6 +2039,8 @@
 		BC42CAAD2BEC9CDA001F076E /* RhythmView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RhythmView.xib; sourceTree = "<group>"; };
 		BC4823CF2C4F5F30000E5401 /* UserDetailModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserDetailModel.h; sourceTree = "<group>"; };
 		BC4823D02C4F5F30000E5401 /* UserDetailModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UserDetailModel.m; sourceTree = "<group>"; };
+		BC4823D22C4F8FBF000E5401 /* KSAccompanyDraftViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KSAccompanyDraftViewController.m; sourceTree = "<group>"; };
+		BC4823D32C4F8FC0000E5401 /* KSAccompanyDraftViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KSAccompanyDraftViewController.h; sourceTree = "<group>"; };
 		BC48322F282A646A005F534C /* HomeRecentCourseView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HomeRecentCourseView.h; sourceTree = "<group>"; };
 		BC483230282A646A005F534C /* HomeRecentCourseView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HomeRecentCourseView.m; sourceTree = "<group>"; };
 		BC483232282A6473005F534C /* HomeRecentCourseView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = HomeRecentCourseView.xib; sourceTree = "<group>"; };
@@ -5019,6 +5022,8 @@
 			isa = PBXGroup;
 			children = (
 				BC38C4002AF900E100ABFCC2 /* AudioMerge */,
+				BC4823D32C4F8FC0000E5401 /* KSAccompanyDraftViewController.h */,
+				BC4823D22C4F8FBF000E5401 /* KSAccompanyDraftViewController.m */,
 			);
 			path = MediaMerge;
 			sourceTree = "<group>";
@@ -7867,6 +7872,7 @@
 				27FC2F6627F1BBFE00FCC239 /* MyMusicViewController.m in Sources */,
 				277D432827E9A48000107DB7 /* ModifyPhoneChangeController.m in Sources */,
 				275FA56227F31AE100EB6240 /* MinePageHeadView.m in Sources */,
+				BC4823D42C4F8FC0000E5401 /* KSAccompanyDraftViewController.m in Sources */,
 				BC76146D280D571B0080FD1F /* HomeworkVideoView.m in Sources */,
 				2755C07427EC905E007D9070 /* GroupMemberModel.m in Sources */,
 				BCECE2252B3D648700C0D555 /* CourseFileDisplayView.m in Sources */,

+ 1 - 1
KulexiuForTeacher/KulexiuForTeacher.xcodeproj/xcshareddata/xcschemes/KulexiuForTeacher.xcscheme

@@ -93,7 +93,7 @@
       buildConfiguration = "Debug">
    </AnalyzeAction>
    <ArchiveAction
-      buildConfiguration = "DEV"
+      buildConfiguration = "TEST"
       revealArchiveInOrganizer = "YES">
    </ArchiveAction>
 </Scheme>

+ 12 - 15
KulexiuForTeacher/KulexiuForTeacher/Common/Base/AccompanyWebView/KSAccompanyWebViewController.m

@@ -22,7 +22,7 @@
 
 // 合成
 #import <KSToolLibrary/KSMediaEditor.h>
-#import "KSMediaMergeView.h"
+#import "KSAccompanyDraftViewController.h"
 
 #import <KSTunerLibrary/KSTunerLibrary-Swift.h>
 #import "KSLogManager.h"
@@ -658,39 +658,36 @@
             }
             // 音视频合成
             else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"openAdjustRecording"]) {
-                KSMediaMergeView *mergeView = [[KSMediaMergeView alloc] init];
+                KSAccompanyDraftViewController *ctrl = [[KSAccompanyDraftViewController alloc] init];
+                ctrl.ks_landScape = YES;
                 if (self.bgAudioUrl == nil) {
                     [LOADING_MANAGER MBShowAUTOHidingInWindow:@"当前曲目无mp3伴奏"];
                 }
                 else {
                     if (self.AQManager && self.AQManager.audioUrl) {
-                        if (self->_videoRecordManager) {
-                            [self.videoRecordManager removeDisplay];
-                        }
+                        
                         self.recordUrl = self.AQManager.audioUrl;
-                        [self.view addSubview:mergeView];
-                        [mergeView mas_makeConstraints:^(MASConstraintMaker *make) {
-                            make.left.right.top.bottom.mas_equalTo(self.view);
-                        }];
+                        
                         NSDictionary *content = [parm ks_dictionaryValueForKey:@"content"];
-                        mergeView.recordId = [content ks_stringValueForKey:@"recordId"];
-                        mergeView.songName = [content ks_stringValueForKey:@"title"];
-                        mergeView.coverImage = [content ks_stringValueForKey:@"coverImg"];
+                        ctrl.recordId = [content ks_stringValueForKey:@"recordId"];
+                        ctrl.songName = [content ks_stringValueForKey:@"title"];
+                        ctrl.coverImage = [content ks_stringValueForKey:@"coverImg"];
                         if ([[content allKeys] containsObject:@"speedRate"]) {
-                            mergeView.musicSpeed = [content ks_floatValueForKey:@"speedRate"];
+                            ctrl.musicSpeed = [content ks_floatValueForKey:@"speedRate"];
                         }
                         else {
-                            mergeView.musicSpeed = 1.0f;
+                            ctrl.musicSpeed = 1.0f;
                         }
                         MJWeakSelf;
                         NSInteger micDelay = [UserDefaultObjectForKey(@"micDelay") integerValue];
                         NSInteger defaultDelay = self.offsetTime + micDelay;
-                        [mergeView configWithVideoUrl:self.videoRecordManager.videoFileURL bgAudioUrl:self.bgAudioUrl remoteBgUrl:self.accompanyUrl  recordUrl:self.recordUrl offsetTime:defaultDelay mergeCallback:^(BOOL isPublished) {
+                        [ctrl configWithVideoUrl:self.videoRecordManager.videoFileURL bgAudioUrl:self.bgAudioUrl remoteBgUrl:self.accompanyUrl  recordUrl:self.recordUrl offsetTime:defaultDelay mergeCallback:^(BOOL isPublished) {
                             [weakSelf appEnterForeground];
                             if (isPublished) {
                                 [weakSelf musicPublishCallBack:content];
                             }
                         }]; 
+                        [self.navigationController pushViewController:ctrl animated:NO];
                     }
                     else {
                         [LOADING_MANAGER MBShowAUTOHidingInWindow:@"麦克风被占用"];

+ 1 - 1
KulexiuForTeacher/KulexiuForTeacher/Common/Base/NavigationController/CustomNavViewController.m

@@ -93,7 +93,7 @@
 #pragma mark - UINavigationControllerDelegate
 
 - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
-    if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)] && ![viewController isKindOfClass:NSClassFromString(@"KSBaseWKWebViewController")] && ![viewController isKindOfClass:NSClassFromString(@"FirstSettingViewController")] && ![viewController isKindOfClass:NSClassFromString(@"TXLiveRoomViewController")] && ![viewController isKindOfClass:NSClassFromString(@"TXClassroomViewController")]) {
+    if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)] && ![viewController isKindOfClass:NSClassFromString(@"KSBaseWKWebViewController")] && ![viewController isKindOfClass:NSClassFromString(@"FirstSettingViewController")] && ![viewController isKindOfClass:NSClassFromString(@"TXLiveRoomViewController")] && ![viewController isKindOfClass:NSClassFromString(@"TXClassroomViewController")] && ![viewController isKindOfClass:NSClassFromString(@"KSAccompanyDraftViewController")]) {
         self.interactivePopGestureRecognizer.enabled = YES;
     }
 }

+ 32 - 0
KulexiuForTeacher/KulexiuForTeacher/Common/MediaMerge/KSAccompanyDraftViewController.h

@@ -0,0 +1,32 @@
+//
+//  KSAccompanyDraftViewController.h
+//  KulexiuForStudent
+//
+//  Created by 王智 on 2024/7/18.
+//
+
+#import "KSBaseViewController.h"
+
+typedef void(^AccompanyMergeCallback)(BOOL isPublished);
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface KSAccompanyDraftViewController : KSBaseViewController
+
+@property (nonatomic, strong) NSString *recordId;
+
+@property (nonatomic, strong) NSString *songName;
+
+@property (nonatomic, strong) NSString *coverImage;
+
+@property (nonatomic, strong) NSString *desc;
+
+@property (nonatomic, assign) float musicSpeed;
+
+
+// 偏移时间 (录制声音和伴奏声音的偏移)offsetTime 收音延迟+ 播放延迟 ms
+- (void)configWithVideoUrl:(NSURL *)videoUrl bgAudioUrl:(NSURL *)bgAudioUrl remoteBgUrl:(NSString *)remoteBgUrl recordUrl:(NSURL *)recordUrl offsetTime:(NSInteger)offsetTime mergeCallback:(AccompanyMergeCallback)callback;
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 113 - 0
KulexiuForTeacher/KulexiuForTeacher/Common/MediaMerge/KSAccompanyDraftViewController.m

@@ -0,0 +1,113 @@
+//
+//  KSAccompanyDraftViewController.m
+//  KulexiuForStudent
+//
+//  Created by 王智 on 2024/7/18.
+//
+
+#import "KSAccompanyDraftViewController.h"
+#import "KSMediaMergeView.h"
+#import "AppDelegate+AppService.h"
+#import <KSToolLibrary/UIDevice+TFDevice.h>
+
+@interface KSAccompanyDraftViewController ()
+
+@property (nonatomic, copy) AccompanyMergeCallback callback;
+
+
+@end
+
+@implementation KSAccompanyDraftViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+    self.ks_prefersNavigationBarHidden = YES;
+}
+
+- (void)changeOrientation:(BOOL)isLandScape {
+    if (isLandScape) {
+        // 切换到横屏
+        if (IS_IPAD) {
+            self.zh_statusBarHidden = YES;
+        }
+        AppDelegate* delegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
+        delegate.allowAutoRotate = YES;
+        [UIDevice switchNewOrientation:UIInterfaceOrientationLandscapeRight inController:self];
+    }
+    else {
+        if (IS_IPAD) {
+            self.zh_statusBarHidden = NO;
+        }
+        AppDelegate* delegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
+        delegate.allowAutoRotate = NO;
+        [UIDevice switchNewOrientation:UIInterfaceOrientationPortrait inController:self];
+    }
+}
+
+- (void)viewWillDisappear:(BOOL)animated {
+    BOOL isBack = [self isViewPopDismiss];
+    if (isBack) {
+        if (self.is_poppingToRoot) {
+            [self changeOrientation:NO];
+            [[UIApplication sharedApplication] setIdleTimerDisabled:NO];
+        }
+    }
+    else {
+        if ([self.presentedViewController isKindOfClass:NSClassFromString(@"TZImagePickerController")] || [self.presentedViewController isKindOfClass:NSClassFromString(@"RSKImageCropViewController")] || [self.presentedViewController isKindOfClass:NSClassFromString(@"KSVideoCropViewController")]) {
+            NSLog(@"-----");
+        }
+        else {
+            KSBaseViewController *nextCtrl = [self getNextViewController];
+            if (nextCtrl) {
+                if (nextCtrl.ks_landScape != self.ks_landScape) {
+                    [self changeOrientation:NO];
+                }
+            }
+        }
+    }
+}
+
+// 偏移时间 (录制声音和伴奏声音的偏移)offsetTime 收音延迟+ 播放延迟 ms
+- (void)configWithVideoUrl:(NSURL *)videoUrl bgAudioUrl:(NSURL *)bgAudioUrl remoteBgUrl:(NSString *)remoteBgUrl recordUrl:(NSURL *)recordUrl offsetTime:(NSInteger)offsetTime mergeCallback:(AccompanyMergeCallback)callback {
+    if (callback) {
+        self.callback = callback;
+    }
+    [self.scrollView removeFromSuperview];
+    
+    KSMediaMergeView *mergeView = [[KSMediaMergeView alloc] init];
+    mergeView.coverImage = self.coverImage;
+    mergeView.songName = self.songName;
+    mergeView.recordId = self.recordId;
+    mergeView.desc = self.desc;
+    mergeView.musicSpeed = self.musicSpeed;
+    MJWeakSelf;
+    [mergeView configWithVideoUrl:videoUrl bgAudioUrl:bgAudioUrl remoteBgUrl:remoteBgUrl recordUrl:recordUrl offsetTime:offsetTime mergeCallback:^(BOOL isPublished) {
+        if (weakSelf.callback) {
+            weakSelf.callback(isPublished);
+            [weakSelf backAction];
+        }
+    }];
+    [self.view addSubview:mergeView];
+    [mergeView mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.right.top.bottom.mas_equalTo(self.view);
+    }];
+}
+
+
+- (void)backAction {
+    [self.view endEditing:YES];
+    // 根据需要返回到不同页面
+    [self.navigationController popViewControllerAnimated:NO];
+}
+/*
+#pragma mark - Navigation
+
+// In a storyboard-based application, you will often want to do a little preparation before navigation
+- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
+    // Get the new view controller using [segue destinationViewController].
+    // Pass the selected object to the new view controller.
+}
+*/
+
+@end