|
|
|
|
@ -192,20 +192,24 @@ class Conductor: ObservableObject { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if let coolSound { |
|
|
|
|
do { |
|
|
|
|
let soundFile = try coolSound.soundFile() |
|
|
|
|
let soundPlayer = SoundPlayer() |
|
|
|
|
self.soundPlayer = soundPlayer |
|
|
|
|
try soundPlayer.playSound(soundFile: soundFile, repeats: false) |
|
|
|
|
} catch { |
|
|
|
|
print("error = \(error)") |
|
|
|
|
// TODO: manage error |
|
|
|
|
} |
|
|
|
|
self.playSound(coolSound) |
|
|
|
|
} else { |
|
|
|
|
print("No sound to play!") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func playSound(_ sound: Sound) { |
|
|
|
|
do { |
|
|
|
|
let soundFile = try sound.soundFile() |
|
|
|
|
let soundPlayer = SoundPlayer() |
|
|
|
|
self.soundPlayer = soundPlayer |
|
|
|
|
try soundPlayer.playSound(soundFile: soundFile, repeats: false) |
|
|
|
|
} catch { |
|
|
|
|
print("error = \(error)") |
|
|
|
|
// TODO: manage error |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func stopSoundIfPossible() { |
|
|
|
|
self.soundPlayer?.stop() |
|
|
|
|
self.soundPlayer = nil |
|
|
|
|
|