KSAccompanyDraftViewController.m 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. //
  2. // KSAccompanyDraftViewController.m
  3. // KulexiuForStudent
  4. //
  5. // Created by 王智 on 2024/7/18.
  6. //
  7. #import "KSAccompanyDraftViewController.h"
  8. #import "KSMediaMergeView.h"
  9. #import "AppDelegate+AppService.h"
  10. #import <KSToolLibrary/UIDevice+TFDevice.h>
  11. @interface KSAccompanyDraftViewController ()
  12. @property (nonatomic, copy) AccompanyMergeCallback callback;
  13. @end
  14. @implementation KSAccompanyDraftViewController
  15. - (void)viewDidLoad {
  16. [super viewDidLoad];
  17. // Do any additional setup after loading the view.
  18. self.ks_prefersNavigationBarHidden = YES;
  19. }
  20. - (void)changeOrientation:(BOOL)isLandScape {
  21. if (isLandScape) {
  22. // 切换到横屏
  23. if (IS_IPAD) {
  24. self.zh_statusBarHidden = YES;
  25. }
  26. AppDelegate* delegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
  27. delegate.allowAutoRotate = YES;
  28. [UIDevice switchNewOrientation:UIInterfaceOrientationLandscapeRight inController:self];
  29. }
  30. else {
  31. if (IS_IPAD) {
  32. self.zh_statusBarHidden = NO;
  33. }
  34. AppDelegate* delegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
  35. delegate.allowAutoRotate = NO;
  36. [UIDevice switchNewOrientation:UIInterfaceOrientationPortrait inController:self];
  37. }
  38. }
  39. - (void)viewWillDisappear:(BOOL)animated {
  40. BOOL isBack = [self isViewPopDismiss];
  41. if (isBack) {
  42. if (self.is_poppingToRoot) {
  43. [self changeOrientation:NO];
  44. [[UIApplication sharedApplication] setIdleTimerDisabled:NO];
  45. }
  46. }
  47. else {
  48. if ([self.presentedViewController isKindOfClass:NSClassFromString(@"TZImagePickerController")] || [self.presentedViewController isKindOfClass:NSClassFromString(@"RSKImageCropViewController")] || [self.presentedViewController isKindOfClass:NSClassFromString(@"KSVideoCropViewController")]) {
  49. NSLog(@"-----");
  50. }
  51. else {
  52. KSBaseViewController *nextCtrl = [self getNextViewController];
  53. if (nextCtrl) {
  54. if (nextCtrl.ks_landScape != self.ks_landScape) {
  55. [self changeOrientation:NO];
  56. }
  57. }
  58. }
  59. }
  60. }
  61. // 偏移时间 (录制声音和伴奏声音的偏移)offsetTime 收音延迟+ 播放延迟 ms
  62. - (void)configWithVideoUrl:(NSURL *)videoUrl bgAudioUrl:(NSURL *)bgAudioUrl remoteBgUrl:(NSString *)remoteBgUrl recordUrl:(NSURL *)recordUrl offsetTime:(NSInteger)offsetTime mergeCallback:(AccompanyMergeCallback)callback {
  63. if (callback) {
  64. self.callback = callback;
  65. }
  66. [self.scrollView removeFromSuperview];
  67. KSMediaMergeView *mergeView = [[KSMediaMergeView alloc] init];
  68. mergeView.coverImage = self.coverImage;
  69. mergeView.songName = self.songName;
  70. mergeView.recordId = self.recordId;
  71. mergeView.desc = self.desc;
  72. mergeView.musicSpeed = self.musicSpeed;
  73. MJWeakSelf;
  74. [mergeView configWithVideoUrl:videoUrl bgAudioUrl:bgAudioUrl remoteBgUrl:remoteBgUrl recordUrl:recordUrl offsetTime:offsetTime mergeCallback:^(BOOL isPublished) {
  75. if (weakSelf.callback) {
  76. weakSelf.callback(isPublished);
  77. [weakSelf backAction];
  78. }
  79. }];
  80. [self.view addSubview:mergeView];
  81. [mergeView mas_makeConstraints:^(MASConstraintMaker *make) {
  82. make.left.right.top.bottom.mas_equalTo(self.view);
  83. }];
  84. }
  85. - (void)backAction {
  86. [self.view endEditing:YES];
  87. // 根据需要返回到不同页面
  88. [self.navigationController popViewControllerAnimated:NO];
  89. }
  90. /*
  91. #pragma mark - Navigation
  92. // In a storyboard-based application, you will often want to do a little preparation before navigation
  93. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  94. // Get the new view controller using [segue destinationViewController].
  95. // Pass the selected object to the new view controller.
  96. }
  97. */
  98. @end