소스 검색

update: 更新iOS端无需在Flutter端手动创建录音文件

hwh97 4 년 전
부모
커밋
8c5cc5683a
1개의 변경된 파일5개의 추가작업 그리고 3개의 파일을 삭제
  1. 5 3
      ios/Classes/FlutterSoundPlugin.m

+ 5 - 3
ios/Classes/FlutterSoundPlugin.m

@@ -235,10 +235,12 @@ NSString* status = [NSString stringWithFormat:@"{\"current_position\": \"%@\"}",
                         error:nil];
 
   [audioRecorder setDelegate:self];
-  [audioRecorder record];
-  [self startRecorderTimer];
+  if([audioRecorder prepareToRecord]) {
+      [audioRecorder record];
+      [self startRecorderTimer];
+      [audioRecorder setMeteringEnabled:shouldProcessDbLevel];
+  }
 
-  [audioRecorder setMeteringEnabled:shouldProcessDbLevel];
   if(shouldProcessDbLevel == true) {
         [self startDbTimer];
   }