투케이2K

59. (ios/swift) 디바이스 사운드 (sound) 재생 수행 실시 - SystemSoundID 본문

IOS

59. (ios/swift) 디바이스 사운드 (sound) 재생 수행 실시 - SystemSoundID

투케이2K 2021. 11. 28. 10:31
반응형

[개발 환경 설정]

개발 툴 : XCODE

개발 언어 : SWIFT

 

[소스 코드]

// MARK: - [extension 정의 실시 : UIDevice]
extension UIDevice {
    // [설명 : 디바이스 사운드 재생 메소드 : 무음 모드일 경우도 소리 재생됨]
    // [필요 import : import AVFoundation]
    // [사용 방법 : UIDevice.sound()]
    static func sound() {
        //AudioServicesPlaySystemSound(SystemSoundID(1003)) // SMSReceived [ReceivedMessage.caf]
        //AudioServicesPlaySystemSound(SystemSoundID(1004)) // SMSReceived [SentMessage.caf]
        //AudioServicesPlaySystemSound(SystemSoundID(1016)) // SMSSent [tweet_sent.caf]
        AudioServicesPlaySystemSound(SystemSoundID(1307)) // SMSReceived_Selection [sms-received1.caf]
    }
}

 
반응형
Comments