YMSoundShowcaseTemplateVoiceView.m 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. //
  2. // YMSoundShowcaseTemplateVoiceView.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/3/8.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMSoundShowcaseTemplateVoiceView.h"
  9. #import "YMSoundShowcaseViewModel.h"
  10. #import "YMRecordSoundView.h"
  11. @interface YMSoundShowcaseTemplateVoiceView ()
  12. /// 声音展示VM
  13. @property (nonatomic, strong) YMSoundShowcaseViewModel *viewModel;
  14. /// 模板录音视图
  15. @property (nonatomic, strong) YMRecordSoundView *templatesVoiceView;
  16. @end
  17. @implementation YMSoundShowcaseTemplateVoiceView
  18. - (void)ym_setupViews{
  19. [self addSubview:self.templatesVoiceView];
  20. [self setNeedsUpdateConstraints];
  21. [self updateConstraintsIfNeeded];
  22. }
  23. - (void)updateConstraints{
  24. [self.templatesVoiceView mas_makeConstraints:^(MASConstraintMaker *make) {
  25. make.top.equalTo(self).offset(adapt(15));
  26. make.left.equalTo(self).offset(adapt(15));
  27. make.right.equalTo(self).offset(adapt(-15));
  28. make.bottom.equalTo(self).offset(adapt(-15));
  29. }];
  30. [super updateConstraints];
  31. }
  32. - (void)ym_bindViewModel:(YMSoundShowcaseViewModel *)viewModel{
  33. if (!viewModel) {
  34. return;
  35. }
  36. _viewModel = viewModel;
  37. }
  38. - (YMRecordSoundView *)templatesVoiceView{
  39. if (!_templatesVoiceView) {
  40. _templatesVoiceView = [[YMRecordSoundView alloc]initWithIsNeedSubmitButton:YES OperationSize:CGSizeMake(adapt(80), adapt(80))];
  41. _templatesVoiceView.minDuration = 5;
  42. _templatesVoiceView.maxDuration = 15;
  43. _templatesVoiceView.rerecordBgColor = UIColor.clearColor;
  44. _templatesVoiceView.submitBgColor = UIColor.clearColor;
  45. _templatesVoiceView.rerecordTitleColor = HexColorFromRGB(0x666666);
  46. _templatesVoiceView.submitTitleColor = HexColorFromRGB(0x666666);
  47. _templatesVoiceView.rerecordBorderColor = UIColor.clearColor;
  48. _templatesVoiceView.submitBorderColor = UIColor.clearColor;
  49. _templatesVoiceView.rerecordImageStr = @"ym_common_record_sound_re_record";
  50. _templatesVoiceView.submitImageStr = @"ym_common_record_sound_submit";
  51. _templatesVoiceView.exportType = YMRecordSoundExportTypeAAC;
  52. @weakify(self)
  53. _templatesVoiceView.exportUrlBlock = ^(NSURL * _Nonnull voiceUrl, NSInteger voiceDuration) {
  54. @strongify(self)
  55. NSLog(@"录音地址%@",voiceUrl);
  56. if (voiceDuration > 0) {
  57. [self.viewModel uploadTemplateVoiceURL:voiceUrl TemplateVoiceDuration:voiceDuration];
  58. }
  59. };
  60. }
  61. return _templatesVoiceView;
  62. }
  63. @end