23 lines
498 B
Swift
23 lines
498 B
Swift
import AppKit
|
|
import AudioToolbox
|
|
|
|
final class AlarmManager {
|
|
static let shared = AlarmManager()
|
|
|
|
private var sound: NSSound?
|
|
|
|
private init() {}
|
|
|
|
func playAlarm() {
|
|
AudioServicesPlaySystemSound(1005)
|
|
|
|
if let url = URL(string: "file:///System/Library/Sounds/Glass.aiff") {
|
|
sound = NSSound(contentsOf: url, byReference: true)
|
|
sound?.volume = 1.0
|
|
sound?.play()
|
|
}
|
|
|
|
NSApp.requestUserAttention(.criticalRequest)
|
|
}
|
|
}
|