Alerts/CriticalAlertAudioPlayer.swift

Trio · Trio/Sources/Services/Alerts/CriticalAlertAudioPlayer.swift · swift · MIT
voice, tag:knn-classified

Module exposing: play, stop, boost, restore

// Source: https://github.com/nightscout/Trio | License: MIT | Copyright 2021 Ivan Valkou
// Provided via justclaw.it.com; keep this notice with the code.
import AudioToolbox
import AVFoundation
import MediaPlayer
import os.log
import UIKit

@MainActor
final class CriticalAlertAudioPlayer {
    private let log = OSLog(subsystem: "org.nightscout.Trio", category: "CriticalAlertAudioPlayer")

    private var player: AVAudioPlayer?
    private var vibrationTimer: Timer?

    private let vibrationInterval: TimeInterval = 2.0
    /// System volume floor for critical alarms. The alarm has to be audible
    /// with the ringer down, but forcing 100% wakes the whole household and
    /// leaves the user no way to turn it down. Raise only up to this floor;
    /// anything already louder is left alo

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key