cancellation sound

main
Laurent 3 years ago
parent f4afba87bb
commit 79f817bf27
  1. 48
      LeCountdown.xcodeproj/project.pbxproj
  2. 81
      LeCountdown/Conductor.swift
  3. BIN
      LeCountdown/Sound_Assets/ESM_Ambient_Game_Menu_Soft_Wood_Confirm_1_Notification_Button_Settings_UI.wav
  4. BIN
      LeCountdown/Sound_Assets/ESM_MVG_fx_ui_one_shot_cancel_clicky_reverb_digital_long.wav
  5. BIN
      LeCountdown/Sound_Assets/ESM_One_Shot_FX_Interface_Glitch_Spaceship_Console_18_Interface_Button_Alert_System_Cm.wav
  6. BIN
      LeCountdown/Sound_Assets/MRKRSTPHR_synth_one_shot_bleep_G.wav
  7. 2
      LeCountdown/Utils/Preferences.swift
  8. 4
      LeCountdown/Views/SettingsView.swift
  9. 1
      LeCountdown/fr.lproj/Localizable.strings

@ -117,6 +117,26 @@
C4A16D9729C4B06400143D5E /* StatePlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A16D9429C4B06400143D5E /* StatePlayer.swift */; };
C4A16D9829C4B06400143D5E /* StatePlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A16D9429C4B06400143D5E /* StatePlayer.swift */; };
C4A16D9929C4B06400143D5E /* StatePlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A16D9429C4B06400143D5E /* StatePlayer.swift */; };
C4A16D9B29D0A7D300143D5E /* MRKRSTPHR_synth_one_shot_bleep_G.wav in Resources */ = {isa = PBXBuildFile; fileRef = C4A16D9A29D0A7D300143D5E /* MRKRSTPHR_synth_one_shot_bleep_G.wav */; };
C4A16D9C29D0A7D300143D5E /* MRKRSTPHR_synth_one_shot_bleep_G.wav in Resources */ = {isa = PBXBuildFile; fileRef = C4A16D9A29D0A7D300143D5E /* MRKRSTPHR_synth_one_shot_bleep_G.wav */; };
C4A16D9D29D0A7D300143D5E /* MRKRSTPHR_synth_one_shot_bleep_G.wav in Resources */ = {isa = PBXBuildFile; fileRef = C4A16D9A29D0A7D300143D5E /* MRKRSTPHR_synth_one_shot_bleep_G.wav */; };
C4A16D9E29D0A7D300143D5E /* MRKRSTPHR_synth_one_shot_bleep_G.wav in Resources */ = {isa = PBXBuildFile; fileRef = C4A16D9A29D0A7D300143D5E /* MRKRSTPHR_synth_one_shot_bleep_G.wav */; };
C4A16D9F29D0A7D300143D5E /* MRKRSTPHR_synth_one_shot_bleep_G.wav in Resources */ = {isa = PBXBuildFile; fileRef = C4A16D9A29D0A7D300143D5E /* MRKRSTPHR_synth_one_shot_bleep_G.wav */; };
C4A16DA129D0A7FE00143D5E /* ESM_One_Shot_FX_Interface_Glitch_Spaceship_Console_18_Interface_Button_Alert_System_Cm.wav in Resources */ = {isa = PBXBuildFile; fileRef = C4A16DA029D0A7FE00143D5E /* ESM_One_Shot_FX_Interface_Glitch_Spaceship_Console_18_Interface_Button_Alert_System_Cm.wav */; };
C4A16DA229D0A7FE00143D5E /* ESM_One_Shot_FX_Interface_Glitch_Spaceship_Console_18_Interface_Button_Alert_System_Cm.wav in Resources */ = {isa = PBXBuildFile; fileRef = C4A16DA029D0A7FE00143D5E /* ESM_One_Shot_FX_Interface_Glitch_Spaceship_Console_18_Interface_Button_Alert_System_Cm.wav */; };
C4A16DA329D0A7FE00143D5E /* ESM_One_Shot_FX_Interface_Glitch_Spaceship_Console_18_Interface_Button_Alert_System_Cm.wav in Resources */ = {isa = PBXBuildFile; fileRef = C4A16DA029D0A7FE00143D5E /* ESM_One_Shot_FX_Interface_Glitch_Spaceship_Console_18_Interface_Button_Alert_System_Cm.wav */; };
C4A16DA429D0A7FE00143D5E /* ESM_One_Shot_FX_Interface_Glitch_Spaceship_Console_18_Interface_Button_Alert_System_Cm.wav in Resources */ = {isa = PBXBuildFile; fileRef = C4A16DA029D0A7FE00143D5E /* ESM_One_Shot_FX_Interface_Glitch_Spaceship_Console_18_Interface_Button_Alert_System_Cm.wav */; };
C4A16DA529D0A7FE00143D5E /* ESM_One_Shot_FX_Interface_Glitch_Spaceship_Console_18_Interface_Button_Alert_System_Cm.wav in Resources */ = {isa = PBXBuildFile; fileRef = C4A16DA029D0A7FE00143D5E /* ESM_One_Shot_FX_Interface_Glitch_Spaceship_Console_18_Interface_Button_Alert_System_Cm.wav */; };
C4A16DA729D0AAA800143D5E /* ESM_Ambient_Game_Menu_Soft_Wood_Confirm_1_Notification_Button_Settings_UI.wav in Resources */ = {isa = PBXBuildFile; fileRef = C4A16DA629D0AAA800143D5E /* ESM_Ambient_Game_Menu_Soft_Wood_Confirm_1_Notification_Button_Settings_UI.wav */; };
C4A16DA829D0AAA800143D5E /* ESM_Ambient_Game_Menu_Soft_Wood_Confirm_1_Notification_Button_Settings_UI.wav in Resources */ = {isa = PBXBuildFile; fileRef = C4A16DA629D0AAA800143D5E /* ESM_Ambient_Game_Menu_Soft_Wood_Confirm_1_Notification_Button_Settings_UI.wav */; };
C4A16DA929D0AAA800143D5E /* ESM_Ambient_Game_Menu_Soft_Wood_Confirm_1_Notification_Button_Settings_UI.wav in Resources */ = {isa = PBXBuildFile; fileRef = C4A16DA629D0AAA800143D5E /* ESM_Ambient_Game_Menu_Soft_Wood_Confirm_1_Notification_Button_Settings_UI.wav */; };
C4A16DAA29D0AAA800143D5E /* ESM_Ambient_Game_Menu_Soft_Wood_Confirm_1_Notification_Button_Settings_UI.wav in Resources */ = {isa = PBXBuildFile; fileRef = C4A16DA629D0AAA800143D5E /* ESM_Ambient_Game_Menu_Soft_Wood_Confirm_1_Notification_Button_Settings_UI.wav */; };
C4A16DAB29D0AAA800143D5E /* ESM_Ambient_Game_Menu_Soft_Wood_Confirm_1_Notification_Button_Settings_UI.wav in Resources */ = {isa = PBXBuildFile; fileRef = C4A16DA629D0AAA800143D5E /* ESM_Ambient_Game_Menu_Soft_Wood_Confirm_1_Notification_Button_Settings_UI.wav */; };
C4A16DAD29D0AB1F00143D5E /* ESM_MVG_fx_ui_one_shot_cancel_clicky_reverb_digital_long.wav in Resources */ = {isa = PBXBuildFile; fileRef = C4A16DAC29D0AB1F00143D5E /* ESM_MVG_fx_ui_one_shot_cancel_clicky_reverb_digital_long.wav */; };
C4A16DAE29D0AB1F00143D5E /* ESM_MVG_fx_ui_one_shot_cancel_clicky_reverb_digital_long.wav in Resources */ = {isa = PBXBuildFile; fileRef = C4A16DAC29D0AB1F00143D5E /* ESM_MVG_fx_ui_one_shot_cancel_clicky_reverb_digital_long.wav */; };
C4A16DAF29D0AB1F00143D5E /* ESM_MVG_fx_ui_one_shot_cancel_clicky_reverb_digital_long.wav in Resources */ = {isa = PBXBuildFile; fileRef = C4A16DAC29D0AB1F00143D5E /* ESM_MVG_fx_ui_one_shot_cancel_clicky_reverb_digital_long.wav */; };
C4A16DB029D0AB1F00143D5E /* ESM_MVG_fx_ui_one_shot_cancel_clicky_reverb_digital_long.wav in Resources */ = {isa = PBXBuildFile; fileRef = C4A16DAC29D0AB1F00143D5E /* ESM_MVG_fx_ui_one_shot_cancel_clicky_reverb_digital_long.wav */; };
C4A16DB129D0AB1F00143D5E /* ESM_MVG_fx_ui_one_shot_cancel_clicky_reverb_digital_long.wav in Resources */ = {isa = PBXBuildFile; fileRef = C4A16DAC29D0AB1F00143D5E /* ESM_MVG_fx_ui_one_shot_cancel_clicky_reverb_digital_long.wav */; };
C4BA2AD62993F62700CB4FBA /* SoundSelectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4BA2AD52993F62700CB4FBA /* SoundSelectionView.swift */; };
C4BA2ADB299549BC00CB4FBA /* TimerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4BA2ADA299549BC00CB4FBA /* TimerModel.swift */; };
C4BA2ADE2995ABA800CB4FBA /* MatriarchFxs_Loop2_Collider.wav in Resources */ = {isa = PBXBuildFile; fileRef = C4BA2ADD2995ABA800CB4FBA /* MatriarchFxs_Loop2_Collider.wav */; };
@ -373,6 +393,10 @@
C498E5A4299152B400E90DE0 /* GreenCheckmarkView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GreenCheckmarkView.swift; sourceTree = "<group>"; };
C4A16D8B29C4A5BA00143D5E /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
C4A16D9429C4B06400143D5E /* StatePlayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatePlayer.swift; sourceTree = "<group>"; };
C4A16D9A29D0A7D300143D5E /* MRKRSTPHR_synth_one_shot_bleep_G.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = MRKRSTPHR_synth_one_shot_bleep_G.wav; sourceTree = "<group>"; };
C4A16DA029D0A7FE00143D5E /* ESM_One_Shot_FX_Interface_Glitch_Spaceship_Console_18_Interface_Button_Alert_System_Cm.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = ESM_One_Shot_FX_Interface_Glitch_Spaceship_Console_18_Interface_Button_Alert_System_Cm.wav; sourceTree = "<group>"; };
C4A16DA629D0AAA800143D5E /* ESM_Ambient_Game_Menu_Soft_Wood_Confirm_1_Notification_Button_Settings_UI.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = ESM_Ambient_Game_Menu_Soft_Wood_Confirm_1_Notification_Button_Settings_UI.wav; sourceTree = "<group>"; };
C4A16DAC29D0AB1F00143D5E /* ESM_MVG_fx_ui_one_shot_cancel_clicky_reverb_digital_long.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = ESM_MVG_fx_ui_one_shot_cancel_clicky_reverb_digital_long.wav; sourceTree = "<group>"; };
C4BA2AD52993F62700CB4FBA /* SoundSelectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SoundSelectionView.swift; sourceTree = "<group>"; };
C4BA2AD72993F7D200CB4FBA /* LeCountdown.0.5.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = LeCountdown.0.5.xcdatamodel; sourceTree = "<group>"; };
C4BA2ADA299549BC00CB4FBA /* TimerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimerModel.swift; sourceTree = "<group>"; };
@ -734,6 +758,10 @@
C415D3CC29C0B13A0037B215 /* Relax */,
C4BA2ADC2995AB7600CB4FBA /* Stephan_Bodzin */,
C4E5D68129B93583008E7465 /* PVP_Stab_Oneshot_Bleep_Em.wav */,
C4A16DA029D0A7FE00143D5E /* ESM_One_Shot_FX_Interface_Glitch_Spaceship_Console_18_Interface_Button_Alert_System_Cm.wav */,
C4A16DA629D0AAA800143D5E /* ESM_Ambient_Game_Menu_Soft_Wood_Confirm_1_Notification_Button_Settings_UI.wav */,
C4A16DAC29D0AB1F00143D5E /* ESM_MVG_fx_ui_one_shot_cancel_clicky_reverb_digital_long.wav */,
C4A16D9A29D0A7D300143D5E /* MRKRSTPHR_synth_one_shot_bleep_G.wav */,
);
path = Sound_Assets;
sourceTree = "<group>";
@ -1037,10 +1065,12 @@
C415D3D529C0B1AB0037B215 /* EX_ATSM_160_Metal_Tonal_Percussion_Sansula_Loop_Call_Am.wav in Resources */,
C4BA2AEA2995AD1C00CB4FBA /* SEM_Synths_Loop4_Nothing_Like_You.wav in Resources */,
C4A16D8C29C4A5BA00143D5E /* GoogleService-Info.plist in Resources */,
C4A16D9B29D0A7D300143D5E /* MRKRSTPHR_synth_one_shot_bleep_G.wav in Resources */,
C415D3CE29C0B1430037B215 /* EX_ATSM_20_Inch_Highwall_Bowl_Hit_Ring_Ab.wav in Resources */,
C415D3ED29C3765B0037B215 /* QP01 0011 Rain soft.wav in Resources */,
C415D3D229C0B1620037B215 /* EX_ATSM_140_Koshi_Chimes_Aria_Tuning_Loop_Wondering_Am.wav in Resources */,
C415D3F929C379700037B215 /* QP01 0050 Deciduous forest morning songbirds robin.wav in Resources */,
C4A16DA129D0A7FE00143D5E /* ESM_One_Shot_FX_Interface_Glitch_Spaceship_Console_18_Interface_Button_Alert_System_Cm.wav in Resources */,
C415D3DE29C0B2230037B215 /* FF_SH_flute_melody_ambient_stacked_profound_Dmin.wav in Resources */,
C473C32C29AA330E0056B38A /* Localizable.strings in Resources */,
C415D3FB29C37A460037B215 /* QP01 0096 Wetland lake early morning.wav in Resources */,
@ -1052,12 +1082,14 @@
C4BA2AE22995ABE700CB4FBA /* SquareArp_Loop_River.wav in Resources */,
C415D3D929C0B1CF0037B215 /* EX_ATSM_Koshi_Chimes_Aria_Tuning_Texture_Longer_Dm.wav in Resources */,
C415D3D729C0B1BF0037B215 /* EX_ATSM_Bell_Binaural_Flam_Eb.wav in Resources */,
C4A16DAD29D0AB1F00143D5E /* ESM_MVG_fx_ui_one_shot_cancel_clicky_reverb_digital_long.wav in Resources */,
C4BA2ADE2995ABA800CB4FBA /* MatriarchFxs_Loop2_Collider.wav in Resources */,
C415D3EF29C376DD0037B215 /* QP01 0017 Stream sparkling.wav in Resources */,
C4BA2AE82995ACC200CB4FBA /* Clave_Loop_LLL.wav in Resources */,
C4E5D67C29B8D4A5008E7465 /* Low_Tom_Disto_Earth.wav in Resources */,
C4BA2AE02995ABD200CB4FBA /* HighChords_Loop_River.wav in Resources */,
C4E5D66D29B753D7008E7465 /* AppShortcuts.strings in Resources */,
C4A16DA729D0AAA800143D5E /* ESM_Ambient_Game_Menu_Soft_Wood_Confirm_1_Notification_Button_Settings_UI.wav in Resources */,
C4060DC4297AE73D003FAB80 /* Assets.xcassets in Resources */,
C415D3DB29C0B1EA0037B215 /* FF_SH_bowl_drone_tap_hold_E.wav in Resources */,
C4BA2AE62995AC3F00CB4FBA /* Loop_ToneSD_Boavista.wav in Resources */,
@ -1068,7 +1100,11 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C4A16DA829D0AAA800143D5E /* ESM_Ambient_Game_Menu_Soft_Wood_Confirm_1_Notification_Button_Settings_UI.wav in Resources */,
C4A16DA229D0A7FE00143D5E /* ESM_One_Shot_FX_Interface_Glitch_Spaceship_Console_18_Interface_Button_Alert_System_Cm.wav in Resources */,
C4A16DAE29D0AB1F00143D5E /* ESM_MVG_fx_ui_one_shot_cancel_clicky_reverb_digital_long.wav in Resources */,
C4A16D8D29C4A5BA00143D5E /* GoogleService-Info.plist in Resources */,
C4A16D9C29D0A7D300143D5E /* MRKRSTPHR_synth_one_shot_bleep_G.wav in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -1076,7 +1112,11 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C4A16DA929D0AAA800143D5E /* ESM_Ambient_Game_Menu_Soft_Wood_Confirm_1_Notification_Button_Settings_UI.wav in Resources */,
C4A16DA329D0A7FE00143D5E /* ESM_One_Shot_FX_Interface_Glitch_Spaceship_Console_18_Interface_Button_Alert_System_Cm.wav in Resources */,
C4A16DAF29D0AB1F00143D5E /* ESM_MVG_fx_ui_one_shot_cancel_clicky_reverb_digital_long.wav in Resources */,
C4A16D8E29C4A5BA00143D5E /* GoogleService-Info.plist in Resources */,
C4A16D9D29D0A7D300143D5E /* MRKRSTPHR_synth_one_shot_bleep_G.wav in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -1084,9 +1124,13 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C4A16DB029D0AB1F00143D5E /* ESM_MVG_fx_ui_one_shot_cancel_clicky_reverb_digital_long.wav in Resources */,
C445FA882984487F0054D761 /* Assets.xcassets in Resources */,
C4A16D9E29D0A7D300143D5E /* MRKRSTPHR_synth_one_shot_bleep_G.wav in Resources */,
C4A16DAA29D0AAA800143D5E /* ESM_Ambient_Game_Menu_Soft_Wood_Confirm_1_Notification_Button_Settings_UI.wav in Resources */,
C438C7DD2981216300BF3EF9 /* Assets.xcassets in Resources */,
C4A16D8F29C4A5BA00143D5E /* GoogleService-Info.plist in Resources */,
C4A16DA429D0A7FE00143D5E /* ESM_One_Shot_FX_Interface_Glitch_Spaceship_Console_18_Interface_Button_Alert_System_Cm.wav in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -1096,6 +1140,10 @@
files = (
C473C33029ACADC80056B38A /* Localizable.strings in Resources */,
C4A16D9029C4A5BA00143D5E /* GoogleService-Info.plist in Resources */,
C4A16DA529D0A7FE00143D5E /* ESM_One_Shot_FX_Interface_Glitch_Spaceship_Console_18_Interface_Button_Alert_System_Cm.wav in Resources */,
C4A16D9F29D0A7D300143D5E /* MRKRSTPHR_synth_one_shot_bleep_G.wav in Resources */,
C4A16DB129D0AB1F00143D5E /* ESM_MVG_fx_ui_one_shot_cancel_clicky_reverb_digital_long.wav in Resources */,
C4A16DAB29D0AAA800143D5E /* ESM_Ambient_Game_Menu_Soft_Wood_Confirm_1_Notification_Button_Settings_UI.wav in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

@ -18,20 +18,21 @@ enum BGTaskIdentifier : String {
}
fileprivate enum Const: String {
case confirmationSound = "PVP_Stab_Oneshot_Bleep_Em.wav"
case confirmationSound = "ESM_Ambient_Game_Menu_Soft_Wood_Confirm_1_Notification_Button_Settings_UI.wav"
case cancellationSound = "ESM_MVG_fx_ui_one_shot_cancel_clicky_reverb_digital_long.wav"
}
class Conductor: ObservableObject {
static let maestro: Conductor = Conductor()
@Published var soundPlayer: SoundPlayer? = nil
fileprivate var _delayedSoundPlayers: [TimerID : DelaySoundPlayer] = [:]
@UserDefault(PreferenceKey.countdowns.rawValue, defaultValue: [:]) static var savedCountdowns: [String : DateInterval]
@UserDefault(PreferenceKey.stopwatches.rawValue, defaultValue: [:]) static var savedStopwatches: [String : Date]
@Published private (set) var liveTimers: [LiveTimer] = []
init() {
@ -44,7 +45,7 @@ class Conductor: ObservableObject {
@Published var currentCountdowns: [String : DateInterval] = [:] {
didSet {
Conductor.savedCountdowns = currentCountdowns
// Logger.log("**** currentCountdowns didSet, count = \(currentCountdowns.count)")
// Logger.log("**** currentCountdowns didSet, count = \(currentCountdowns.count)")
withAnimation {
self._buildLiveTimers()
}
@ -87,7 +88,7 @@ class Conductor: ObservableObject {
self.liveTimers.append(liveCountdown)
}
}
let liveStopwatches = self.currentStopwatches.map {
return LiveTimer(id: $0, date: $1)
}
@ -103,14 +104,14 @@ class Conductor: ObservableObject {
}
func notifyUser(countdownId: String) {
// self._playSound(timerId: countdownId)
// self._playSound(timerId: countdownId)
self._endCountdown(countdownId: countdownId, cancel: false)
}
fileprivate func _recordActivity(countdownId: String) {
let context = PersistenceController.shared.container.viewContext
if let countdown = context.object(stringId: countdownId) as? Countdown,
let dateInterval = self.currentCountdowns[countdownId] {
let dateInterval = self.currentCountdowns[countdownId] {
do {
try CoreDataRequests.recordActivity(timer: countdown, dateInterval: dateInterval)
} catch {
@ -121,34 +122,38 @@ class Conductor: ObservableObject {
}
// MARK: - Countdown
// func startCountdown(_ date: Date, countdown: Countdown) {
//// DispatchQueue.main.async {
//
// Logger.log("Starts countdown: \(countdown.displayName)")
//
// // cleanup existing countdowns
// self.removeLiveTimer(id: countdown.stringId)
//
//// self._cleanupTimers.removeValue(forKey: countdown.stringId)
//
// let dateInterval = DateInterval(start: Date(), end: date)
// self.currentCountdowns[countdown.stringId] = dateInterval
//
//// self._launchLiveActivity(countdown: countdown, endDate: date)
//
//// self._createTimerIntent(countdown)
//
//// Logger.log("countdowns count = \(self.currentCountdowns.count)")
//
//// }
// }
// func startCountdown(_ date: Date, countdown: Countdown) {
//// DispatchQueue.main.async {
//
// Logger.log("Starts countdown: \(countdown.displayName)")
//
// // cleanup existing countdowns
// self.removeLiveTimer(id: countdown.stringId)
//
//// self._cleanupTimers.removeValue(forKey: countdown.stringId)
//
// let dateInterval = DateInterval(start: Date(), end: date)
// self.currentCountdowns[countdown.stringId] = dateInterval
//
//// self._launchLiveActivity(countdown: countdown, endDate: date)
//
//// self._createTimerIntent(countdown)
//
//// Logger.log("countdowns count = \(self.currentCountdowns.count)")
//
//// }
// }
func cancelCountdown(id: TimerID) {
CountdownScheduler.master.cancelCurrentNotifications(countdownId: id)
self.cancelSoundPlayer(id: id)
self.cancelledCountdowns.append(id)
self._endCountdown(countdownId: id, cancel: true)
if Preferences.playCancellationSound {
self._playCancellationSound()
}
}
fileprivate func _endCountdown(countdownId: String, cancel: Bool) {
@ -166,20 +171,20 @@ class Conductor: ObservableObject {
do {
let date = Date(timeIntervalSinceNow: countdown.duration)
self.removeLiveTimer(id: countdown.stringId)
let soundFile = try SoundFile(fullName: countdown.soundName)
let soundPlayer = try DelaySoundPlayer(timerID: countdown.stringId, soundFile: soundFile)
self._delayedSoundPlayers[countdown.stringId] = soundPlayer
try soundPlayer.start(in: countdown.duration,
repeatCount: Int(countdown.repeatCount))
repeatCount: Int(countdown.repeatCount))
let dateInterval = DateInterval(start: Date(), end: date)
self.currentCountdowns[countdown.stringId] = dateInterval
if Preferences.playConfirmationSound {
self._playSound(Const.confirmationSound.rawValue)
self._playConfirmationSound()
}
handler(.success(date))
@ -282,7 +287,15 @@ class Conductor: ObservableObject {
}
AudioServicesPlayAlertSound(SystemSoundID(kSystemSoundID_Vibrate))
}
fileprivate func _playConfirmationSound() {
self._playSound(Const.confirmationSound.rawValue)
}
fileprivate func _playCancellationSound() {
self._playSound(Const.cancellationSound.rawValue)
}
func playSound(_ sound: Sound) {
self._playSound(sound.fileName)
}

@ -11,6 +11,7 @@ enum PreferenceKey: String {
case countdowns
case stopwatches
case playConfirmationSound
case playCancellationSound
case showSilentModeAlert
case soundDurations
case lastSoundPlayed
@ -27,6 +28,7 @@ class Preferences {
@UserDefault(PreferenceKey.tips.rawValue, defaultValue: nil) static var lastShownTip: Int?
@UserDefault(PreferenceKey.timerSiriTips.rawValue, defaultValue: []) static var timerSiriTips: Set<String>
@UserDefault(PreferenceKey.playConfirmationSound.rawValue, defaultValue: true) static var playConfirmationSound: Bool
@UserDefault(PreferenceKey.playCancellationSound.rawValue, defaultValue: true) static var playCancellationSound: Bool
@UserDefault(PreferenceKey.cloudKitSchemaInitialized.rawValue, defaultValue: false) static var cloudKitSchemaInitialized: Bool
static var hideSilentModeAlerts: Bool {

@ -10,6 +10,7 @@ import SwiftUI
struct SettingsView: View {
@State var confirmationSound = Preferences.playConfirmationSound
@State var cancellationSound = Preferences.playCancellationSound
@State var showMailView: Bool = false
@ -19,6 +20,9 @@ struct SettingsView: View {
Toggle("Play confirmation sound", isOn: self.$confirmationSound).onChange(of: self.confirmationSound) { newValue in
Preferences.playConfirmationSound = newValue
}
Toggle("Play cancellation sound", isOn: self.$cancellationSound).onChange(of: self.cancellationSound) { newValue in
Preferences.playCancellationSound = newValue
}
Button {
self.showMailView = true
} label: {

@ -252,4 +252,5 @@
"Pasta" = "Pasta";
"Rice" = "Riz";
"Play confirmation sound" = "Jouer son de confirmation";
"Play cancellation sound" = "Jouer son d'annulation";
"Contact us" = "Contactez-nous";

Loading…
Cancel
Save