AudioServicesPlaySystemSound(_:)
Plays a system sound object.
Declaration
func AudioServicesPlaySystemSound(_ inSystemSoundID: SystemSoundID)Parameters
- inSystemSoundID:
The system sound to play. Before using this function, call the Audioservicescreatesystemsoundid(_:_:) function to obtain a system sound.
Discussion
This function plays a short sound (30 seconds or less in duration). Because sound might play for several seconds, this function is executed asynchronously. To know when a sound has finished playing, call the AudioServicesAddSystemSoundCompletion(_:_:_:_:_:) function to register a callback function.
On some iOS devices, you can pass the kSystemSoundID_Vibrate constant to invoke vibration. On other iOS devices, calling this function with that constant does nothing.
Sound files that you play using this function must be:
No longer than 30 seconds in duration
In linear PCM or IMA4 (IMA/ADPCM) format
Packaged in a
.caf,.aif, or.wavfile
In addition, when you use the AudioServicesPlaySystemSound function:
Sounds play at the current system audio volume, with no programmatic volume control available
Sounds play immediately
Looping and stereo positioning are unavailable
Simultaneous playback is unavailable: You can play only one sound at a time
The sound is played locally on the device speakers; it does not use audio routing.