Skip to content

Commit d149289

Browse files
authored
Flutter example: swift fixes (#143)
1 parent 2c4be65 commit d149289

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

evi-flutter-example/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
*.swp
66
.DS_Store
77
.atom/
8+
.build/
89
.buildlog/
910
.history
1011
.svn/
12+
.swiftpm/
1113
migrate_working_dir/
1214

1315
# Environment variables related

evi-flutter-example/audio/ios/Classes/SoundPlayer.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ public class SoundPlayer: NSObject, AVAudioPlayerDelegate {
3939
do {
4040
try playNextInQueue()
4141
} catch {
42-
self.onError?(error as! SoundPlayerError)
42+
if let soundError = error as? SoundPlayerError {
43+
self.onError?(soundError)
44+
} else {
45+
self.onError?(SoundPlayerError.decodeError(details: error.localizedDescription))
46+
}
4347
}
4448
}
4549
}
@@ -59,8 +63,9 @@ public class SoundPlayer: NSObject, AVAudioPlayerDelegate {
5963
self.audioPlayer!.prepareToPlay()
6064
self.audioPlayer!.delegate = self
6165
let result = audioPlayer!.play()
62-
63-
let isSpeaker = session.currentRoute.outputs.first?.portType == AVAudioSession.Port.builtInSpeaker
66+
67+
let isSpeaker =
68+
session.currentRoute.outputs.first?.portType == AVAudioSession.Port.builtInSpeaker
6469
if isSpeaker {
6570
// This is to work around an issue with AVFoundation and voiceProcessing: https://forums.developer.apple.com/forums/thread/721535
6671
self.audioPlayer!.volume = 1.0

evi-flutter-example/audio/lib/audio.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Audio {
2525
final audioData = event['data'] as String;
2626
_audioController.add(audioData);
2727
} else if (event['type'] == 'error') {
28-
final error = event['data'] as String;
28+
final error = event['message'] as String;
2929
_audioController.addError(error);
3030
}
3131
}

0 commit comments

Comments
 (0)