| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- //
- // 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
|