Browse Source

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

hwh97 4 years ago
parent
commit
8c5cc5683a
1 changed files with 5 additions and 3 deletions
  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];
   }