瀏覽代碼

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];
   }