mirror of
https://github.com/GLEGram/GLEGram-iOS.git
synced 2026-04-24 11:56:18 +02:00
4647310322
Based on Swiftgram 12.5 (Telegram iOS 12.5). All GLEGram features ported and organized in GLEGram/ folder. Features: Ghost Mode, Saved Deleted Messages, Content Protection Bypass, Font Replacement, Fake Profile, Chat Export, Plugin System, and more. See CHANGELOG_12.5.md for full details.
58 lines
1.6 KiB
Swift
58 lines
1.6 KiB
Swift
import Foundation
|
|
import SwiftSignalKit
|
|
import AudioToolbox
|
|
import AppBundle
|
|
|
|
private func loadSystemSoundFromBundle(name: String) -> SystemSoundID? {
|
|
let path = "\(getAppBundle().resourcePath!)/\(name)"
|
|
let url = URL(fileURLWithPath: path)
|
|
var sound: SystemSoundID = 0
|
|
if AudioServicesCreateSystemSoundID(url as CFURL, &sound) == noErr {
|
|
return sound
|
|
}
|
|
return nil
|
|
}
|
|
|
|
public final class ServiceSoundManager {
|
|
private let queue = Queue()
|
|
private var messageDeliverySound: SystemSoundID?
|
|
private var incomingMessageSound: SystemSoundID?
|
|
|
|
init() {
|
|
self.queue.async {
|
|
self.messageDeliverySound = loadSystemSoundFromBundle(name: "MessageSent.mp3")
|
|
self.incomingMessageSound = loadSystemSoundFromBundle(name: "notification.mp3")
|
|
}
|
|
}
|
|
|
|
public func playMessageDeliveredSound() {
|
|
self.queue.async {
|
|
if let messageDeliverySound = self.messageDeliverySound {
|
|
AudioServicesPlaySystemSound(messageDeliverySound)
|
|
}
|
|
}
|
|
}
|
|
|
|
public func playIncomingMessageSound() {
|
|
self.queue.async {
|
|
if let incomingMessageSound = self.incomingMessageSound {
|
|
AudioServicesPlaySystemSound(incomingMessageSound)
|
|
}
|
|
}
|
|
}
|
|
|
|
public func playVibrationSound() {
|
|
self.queue.async {
|
|
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate)
|
|
}
|
|
}
|
|
|
|
public func playLockSound() {
|
|
self.queue.async {
|
|
AudioServicesPlaySystemSound(1100)
|
|
}
|
|
}
|
|
}
|
|
|
|
public let serviceSoundManager = ServiceSoundManager()
|