Steven 8 months ago
parent
commit
5204818789

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

@@ -917,6 +917,7 @@
 		BCF472EA2AB01AEB0032BE16 /* TenantMoreViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BCF472E92AB01AEB0032BE16 /* TenantMoreViewController.m */; };
 		BCFC09C82C47F6AD009A727F /* KSToolLibrary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BCFC09C72C47F6AD009A727F /* KSToolLibrary.framework */; };
 		BCFC09CA2C47F6FF009A727F /* CloudAccompanyLibrary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BCFC09C92C47F6FF009A727F /* CloudAccompanyLibrary.framework */; };
+		BCFC09D12C48B3D7009A727F /* KSAccompanyDraftViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BCFC09D02C48B3D7009A727F /* KSAccompanyDraftViewController.m */; };
 		BCFCE44E28DD5C000051FED8 /* Low.wav in Resources */ = {isa = PBXBuildFile; fileRef = BCFCE44C28DD5C000051FED8 /* Low.wav */; };
 		BCFCE44F28DD5C000051FED8 /* High.wav in Resources */ = {isa = PBXBuildFile; fileRef = BCFCE44D28DD5C000051FED8 /* High.wav */; };
 		BCFDA61228BC8FCE0022B497 /* HomeHotVideoCell.m in Sources */ = {isa = PBXBuildFile; fileRef = BCFDA61028BC8FCE0022B497 /* HomeHotVideoCell.m */; };
@@ -2488,6 +2489,8 @@
 		BCF880E02B91C5150007B8F0 /* Config-release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Config-release.xcconfig"; sourceTree = "<group>"; };
 		BCFC09C72C47F6AD009A727F /* KSToolLibrary.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = KSToolLibrary.framework; sourceTree = "<group>"; };
 		BCFC09C92C47F6FF009A727F /* CloudAccompanyLibrary.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CloudAccompanyLibrary.framework; sourceTree = "<group>"; };
+		BCFC09CF2C48B3D7009A727F /* KSAccompanyDraftViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KSAccompanyDraftViewController.h; sourceTree = "<group>"; };
+		BCFC09D02C48B3D7009A727F /* KSAccompanyDraftViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KSAccompanyDraftViewController.m; sourceTree = "<group>"; };
 		BCFCE44C28DD5C000051FED8 /* Low.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = Low.wav; sourceTree = "<group>"; };
 		BCFCE44D28DD5C000051FED8 /* High.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = High.wav; sourceTree = "<group>"; };
 		BCFDA60F28BC8FCE0022B497 /* HomeHotVideoCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HomeHotVideoCell.h; sourceTree = "<group>"; };
@@ -4470,6 +4473,8 @@
 				BC38C3E12AF893B300ABFCC2 /* KSPlayerView.h */,
 				BC38C3D52AF893B300ABFCC2 /* KSPlayerView.m */,
 				BC38C3DA2AF893B300ABFCC2 /* VideoPlayerView */,
+				BCFC09CF2C48B3D7009A727F /* KSAccompanyDraftViewController.h */,
+				BCFC09D02C48B3D7009A727F /* KSAccompanyDraftViewController.m */,
 			);
 			path = AudioMerge;
 			sourceTree = "<group>";
@@ -7170,6 +7175,7 @@
 				BC542E612840A60E00633781 /* UseBodyView.m in Sources */,
 				BCC0F6C22A8CDDEB00C4EFA4 /* Whiteboard.m in Sources */,
 				BC8A45A6283DC33400094BBB /* ScoreAnimationView.m in Sources */,
+				BCFC09D12C48B3D7009A727F /* KSAccompanyDraftViewController.m in Sources */,
 				BC2DFF4E28BE068D0056105A /* TeacherStyleFlowLayout.m in Sources */,
 				BC38C4582AFA095D00ABFCC2 /* MineWorksOpenDisplayCell.m in Sources */,
 				BCB635A627F6D90600ACFDCF /* KSLiveEmptyView.m in Sources */,

+ 32 - 0
KulexiuForStudent/KulexiuForStudent/Common/MediaMerge/AudioMerge/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
KulexiuForStudent/KulexiuForStudent/Common/MediaMerge/AudioMerge/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