Skip to content
Snippets Groups Projects
Commit ff443452 authored by Bruno Muniz's avatar Bruno Muniz :apple:
Browse files

Merge branch 'fix/dictation-crash' into 'dev'

Fix crash with dictation and audio recording

See merge request elixxir/client-ios!110
parents 8acde7cc 33b3a86f
No related branches found
No related tags found
1 merge request!110Fix crash with dictation and audio recording
......@@ -41,8 +41,12 @@ public final class Voxophone: NSObject, AVAudioRecorderDelegate, AVAudioPlayerDe
public func load(_ url: URL) {
destroyPlayer()
destroyRecorder()
let player = setupPlayer(url: url)
do {
let player = try setupPlayer(url: url)
state = .idle(url, duration: player.duration, isLoudspeaker: state.isLoudspeaker)
} catch {
state = .empty(isLoudspeaker: state.isLoudspeaker)
}
}
public func play() {
......@@ -76,8 +80,8 @@ public final class Voxophone: NSObject, AVAudioRecorderDelegate, AVAudioPlayerDe
}
}
private func setupPlayer(url: URL) -> AVAudioPlayer {
let player = try! AVAudioPlayer(contentsOf: url, fileTypeHint: AVFileType.m4a.rawValue)
private func setupPlayer(url: URL) throws -> AVAudioPlayer {
let player = try AVAudioPlayer(contentsOf: url, fileTypeHint: AVFileType.m4a.rawValue)
self.player = player
return player
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment