Skip to content

Commit 0bfadf1

Browse files
committed
Applied PR rmbrone#45
1 parent c45e135 commit 0bfadf1

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

ios/Classes/SwiftFlutterAudioRecorderPlugin.swift

+8-1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ public class SwiftFlutterAudioRecorderPlugin: NSObject, FlutterPlugin, AVAudioRe
6464
AVNumberOfChannelsKey: 1,
6565
AVEncoderAudioQualityKey: AVAudioQuality.high.rawValue
6666
]
67+
68+
guard let destinationUrl = URL(string: mPath) else {
69+
let errorMessage = "Failed to initialize URL path from string: \(mPath)"
70+
print(errorMessage)
71+
result(FlutterError(code: "", message: errorMessage, details: error))
72+
return
73+
}
6774

6875
do {
6976
#if swift(>=4.2)
@@ -72,7 +79,7 @@ public class SwiftFlutterAudioRecorderPlugin: NSObject, FlutterPlugin, AVAudioRe
7279
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord, with: AVAudioSessionCategoryOptions.defaultToSpeaker)
7380
#endif
7481
try AVAudioSession.sharedInstance().setActive(true)
75-
audioRecorder = try AVAudioRecorder(url: URL(string: mPath)!, settings: settings)
82+
audioRecorder = try AVAudioRecorder(url: destinationUrl, settings: settings)
7683
audioRecorder.delegate = self
7784
audioRecorder.isMeteringEnabled = true
7885
audioRecorder.prepareToRecord()

0 commit comments

Comments
 (0)