Aila_EnableSpeaker
Enable audio playback through speaker and disable modem communications.
Signature
- Objective-C
- Swift
void Aila_EnableSpeaker(void);
func Aila_EnableSpeaker()
Description
Enables audio output to be played through the Apple device's built-in speaker. Since the Aila SDK communicates over the audio jack (on Lightning-based iPads), communication between Aila Hardware and the SDK will not function as long as the speaker is enabled.
This will cause the kiosk illumination to stop after 10 seconds. This can be overridden to support scenarios where audio needs to be played (e.g., voiceovers for ADA or videos with audio). See Aila_OverrideLightTimeout() for details.
This function may block for up to 1 second, depending on hardware and iOS version.
This feature only applies to Lightning-based iPads when connected to a kiosk over the audio jack.
The System Sound Services API (AudioServicesCreateSystemSoundID, AudioServicesPlaySystemSound, etc.) does not respect audio route overrides. Sound played using System Sound Services will not play over the speaker. APIs that do respect audio route overrides (e.g., AVAudioPlayer) should be used instead.
Usage
- Objective-C
- Swift
// Enable speaker for audio playback
Aila_EnableSpeaker();
// Play audio using AVAudioPlayer
NSURL *audioURL = [[NSBundle mainBundle] URLForResource:@"audio" withExtension:@"mp3"];
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:audioURL error:nil];
[player play];
// When done, disable speaker to restore communications
Aila_DisableSpeaker();
// Enable speaker for audio playback
Aila_EnableSpeaker()
// Play audio using AVAudioPlayer
if let audioURL = Bundle.main.url(forResource: "audio", withExtension: "mp3") {
let player = try? AVAudioPlayer(contentsOf: audioURL)
player?.play()
}
// When done, disable speaker to restore communications
Aila_DisableSpeaker()
See Also
- Aila_DisableSpeaker - Disable speaker and re-enable communications
- Aila_OverrideLightTimeout - Keep lighting active during audio