Throws exception if player returns false when playing at time

main
Laurent 3 years ago
parent b709b6da24
commit b873be1e29
  1. 4
      LeCountdown/Sound/DelaySoundPlayer.swift
  2. 1
      LeCountdown/Sound/SoundPlayer.swift

@ -48,6 +48,10 @@ import AVFoundation
let time: TimeInterval = self._player.deviceCurrentTime + duration
let result = self._player.play(atTime: time)
FileLogger.log("play \(String(describing: self._player.url)) >atTime: \(time), result = \(result), isMainThread = \(Thread.isMainThread)")
if !result {
throw SoundPlayerError.playReturnedFalse
}
}
func stop() {

@ -31,6 +31,7 @@ struct SoundFile {
enum SoundPlayerError : Error {
case missingResourceError(file: SoundFile)
case badFileName(name: String)
case playReturnedFalse
}
@objc class SoundPlayer: NSObject, AVAudioPlayerDelegate {

Loading…
Cancel
Save