1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- //
- // YMSoundShowcaseTemplateVoiceView.m
- // MSYOUPAI
- //
- // Created by YoMi on 2024/3/8.
- // Copyright © 2024 MS. All rights reserved.
- //
- #import "YMSoundShowcaseTemplateVoiceView.h"
- #import "YMSoundShowcaseViewModel.h"
- #import "YMRecordSoundView.h"
- @interface YMSoundShowcaseTemplateVoiceView ()
- /// 声音展示VM
- @property (nonatomic, strong) YMSoundShowcaseViewModel *viewModel;
- /// 模板录音视图
- @property (nonatomic, strong) YMRecordSoundView *templatesVoiceView;
- @end
- @implementation YMSoundShowcaseTemplateVoiceView
- - (void)ym_setupViews{
-
- [self addSubview:self.templatesVoiceView];
- [self setNeedsUpdateConstraints];
- [self updateConstraintsIfNeeded];
- }
- - (void)updateConstraints{
-
- [self.templatesVoiceView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self).offset(adapt(15));
- make.left.equalTo(self).offset(adapt(15));
- make.right.equalTo(self).offset(adapt(-15));
- make.bottom.equalTo(self).offset(adapt(-15));
- }];
- [super updateConstraints];
- }
- - (void)ym_bindViewModel:(YMSoundShowcaseViewModel *)viewModel{
- if (!viewModel) {
- return;
- }
-
- _viewModel = viewModel;
-
- }
- - (YMRecordSoundView *)templatesVoiceView{
- if (!_templatesVoiceView) {
- _templatesVoiceView = [[YMRecordSoundView alloc]initWithIsNeedSubmitButton:YES OperationSize:CGSizeMake(adapt(80), adapt(80))];
- _templatesVoiceView.minDuration = 5;
- _templatesVoiceView.maxDuration = 15;
- _templatesVoiceView.rerecordBgColor = UIColor.clearColor;
- _templatesVoiceView.submitBgColor = UIColor.clearColor;
- _templatesVoiceView.rerecordTitleColor = HexColorFromRGB(0x666666);
- _templatesVoiceView.submitTitleColor = HexColorFromRGB(0x666666);
- _templatesVoiceView.rerecordBorderColor = UIColor.clearColor;
- _templatesVoiceView.submitBorderColor = UIColor.clearColor;
- _templatesVoiceView.rerecordImageStr = @"ym_common_record_sound_re_record";
- _templatesVoiceView.submitImageStr = @"ym_common_record_sound_submit";
- _templatesVoiceView.exportType = YMRecordSoundExportTypeAAC;
- @weakify(self)
- _templatesVoiceView.exportUrlBlock = ^(NSURL * _Nonnull voiceUrl, NSInteger voiceDuration) {
- @strongify(self)
- NSLog(@"录音地址%@",voiceUrl);
- if (voiceDuration > 0) {
- [self.viewModel uploadTemplateVoiceURL:voiceUrl TemplateVoiceDuration:voiceDuration];
- }
-
- };
- }
- return _templatesVoiceView;
- }
- @end
|