|
|
|
|
@ -69,7 +69,7 @@ class Conductor: ObservableObject { |
|
|
|
|
self.currentStopwatches.removeValue(forKey: id) |
|
|
|
|
self.cancelledCountdowns.removeAll(where: { $0 == id }) |
|
|
|
|
if let soundPlayer = self._delayedSoundPlayers[id] { |
|
|
|
|
FileLogger.log("Stop sound player: \(id)") |
|
|
|
|
FileLogger.log("Stop sound player: \(self._timerName(id))") |
|
|
|
|
soundPlayer.stop() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -80,8 +80,6 @@ class Conductor: ObservableObject { |
|
|
|
|
|
|
|
|
|
fileprivate func _buildLiveTimers() { |
|
|
|
|
|
|
|
|
|
// Logger.log("_buildLiveTimers") |
|
|
|
|
|
|
|
|
|
let liveCountdowns = self.currentCountdowns.map { |
|
|
|
|
return LiveTimer(id: $0, date: $1.end) |
|
|
|
|
} |
|
|
|
|
@ -144,7 +142,7 @@ class Conductor: ObservableObject { |
|
|
|
|
do { |
|
|
|
|
let start = Date() |
|
|
|
|
let end = start.addingTimeInterval(countdown.duration) |
|
|
|
|
FileLogger.log("schedule countdown \(countdownId) at \(end)") |
|
|
|
|
FileLogger.log("schedule countdown \(self._timerName(countdownId)) at \(end)") |
|
|
|
|
|
|
|
|
|
let sound = countdown.someSound |
|
|
|
|
let soundPlayer = try DelaySoundPlayer(timerID: countdownId, sound: sound) |
|
|
|
|
@ -183,7 +181,7 @@ class Conductor: ObservableObject { |
|
|
|
|
|
|
|
|
|
func cancelCountdown(id: TimerID) { |
|
|
|
|
|
|
|
|
|
FileLogger.log("Cancel \(id)") |
|
|
|
|
FileLogger.log("Cancel \(self._timerName(id))") |
|
|
|
|
CountdownScheduler.master.cancelCurrentNotifications(countdownId: id) |
|
|
|
|
self.cancelSoundPlayer(id: id) |
|
|
|
|
self.cancelledCountdowns.append(id) |
|
|
|
|
@ -256,7 +254,7 @@ class Conductor: ObservableObject { |
|
|
|
|
let sound: Sound = countdown.someSound |
|
|
|
|
let soundPlayer = try DelaySoundPlayer(timerID: countdownId, sound: sound) |
|
|
|
|
self._delayedSoundPlayers[countdown.stringId] = soundPlayer |
|
|
|
|
FileLogger.log("Restored sound player for \(countdown.stringId)") |
|
|
|
|
FileLogger.log("Restored sound player for \(self._timerName(countdownId))") |
|
|
|
|
try soundPlayer.restore(for: interval.end, repeatCount: Int(countdown.repeatCount)) |
|
|
|
|
} catch { |
|
|
|
|
Logger.error(error) |
|
|
|
|
@ -357,7 +355,7 @@ class Conductor: ObservableObject { |
|
|
|
|
if let soundPlayer = self._delayedSoundPlayers[id] { |
|
|
|
|
soundPlayer.stop() |
|
|
|
|
self._delayedSoundPlayers.removeValue(forKey: id) |
|
|
|
|
FileLogger.log("cancelled sound player for \(id)") |
|
|
|
|
FileLogger.log("cancelled sound player for \(self._timerName(id))") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
self.deactivateAudioSessionIfPossible() |
|
|
|
|
@ -457,4 +455,8 @@ class Conductor: ObservableObject { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fileprivate func _timerName(_ id: TimerID) -> String { |
|
|
|
|
return IntentDataProvider.main.timer(id: id)?.name ?? id |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|