Audio
class Audio : ObservableObject
An observable class that publishes standard system sounds. It also provides audio functions that the client can call.
-
an os logger with the Audio category
Declaration
Swift
let logger: Logger
-
The items used in the SwiftUI List
Declaration
Swift
@Published var sysSounds: [SysSound] { get set }
-
a local handle
Declaration
Swift
var serena: SystemSoundID
-
Get the ball rolling. Setup the Audio Session, and find the session sounds
Declaration
Swift
init()
-
A client side callable function. Hides the details. This will create a system sound for a custom sound file and play it.
Declaration
Swift
func playSerena()
-
Play vibrate as an alert sound. and as a system sound
Declaration
Swift
func vibrate()
-
Play vibrate alert sound repeatedly
Declaration
Swift
func annoy()
-
Find all of the standard system sounds.
Declaration
Swift
func findSystemSounds() -> [URL]?
Return Value
An array of the file urls to the system sounds.
-
Find the standard system sounds, skipping the subdirectories.
Declaration
Swift
func findSystemSoundsNonRecursive() -> [URL]?
Return Value
An array of the file urls to the system sounds.
-
Display a more meaningful string from an error code.
Declaration
Swift
func checkSysSoundError(osstatus: OSStatus)
Parameters
osstatus
The error code
-
Plays a system sound.
Declaration
Swift
func playSystemSound(url: URL)
Parameters
url
The file URL to the sound file
-
Create a System sound from a custom sound file.
Declaration
Swift
func createSysSound(fileName: String, fileExt: String) -> SystemSoundID
Parameters
fileName
The base name of the sound file.
fileExt
The file extension.
Return Value
a SystemSoundID that can be played
-
Get the contents of a directory sorted
Declaration
Swift
func dirsFilteredAndSorted(directoryURL: URL)
Parameters
directoryURL
The directory you want to list
-
Another way to list the contents of the system sounds directory
Declaration
Swift
func filesWithErrorHandlerAndProperties() -> [URL]?
Return Value
an array of URLs representing the files in that directory.
-
Set the “is UI sound” property on the given sound. If set, it will be silent if the user chooses to turn off sound effects.
Declaration
Swift
func setUISound(soundID: SystemSoundID, value: UInt32)
Parameters
soundID
the sound whose property will be set
value
1 for true, 0 for false
-
Check to see if the sounds has the UISound property set
Declaration
Swift
func isUISound(soundID: SystemSoundID) -> Bool
Parameters
soundID
the sound to check
Return Value
true if the property is set, false if not
-
Add a completion callback to vibrate. Call this only once. Otherwise you get a kAudioServicesSystemSoundUnspecifiedError error. But it doesn’t work! Doesn’t really matter because the other play functions have completions that work.
Declaration
Swift
func registerVibrateCompletion()
-
Unregister the vibrate completion
Declaration
Swift
func removeVibrateCompletion()
-
Set the Audio session to playback and activate it
Declaration
Swift
func setSessionPlayback()
-
Undocumented
Declaration
Swift
deinit