SINAudioController Protocol Reference
Conforms to | NSObject |
---|---|
Declared in | SINAudioController.h |
Overview
The SINAudioController provides methods for controlling audio related functionality, e.g. enabling the speaker, muting the microphone, and playing sound files.
Playing Sound Files
The audio controller provides a convenience method (startPlayingSoundFile:loop:) for playing sounds that are related to a call, such as ringtones and busy tones.
Example
id<SINAudioController> audio = [client audioController];
NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"ringtone"
ofType:@"wav"];
[audio startPlayingSoundFile:soundPath loop:YES];
Applications that prefer to use their own code for playing sounds are free to do so, but they should follow a few guidelines related to audio session categories and audio session activation/deactivation (see Sinch SDK User Guide for details).
Sound File Format
The sound file must be a mono (1 channel), 16-bit, uncompressed (PCM) .wav file with a sample rate of 8kHz, 16kHz, or 32kHz.
delegate
required method
The object that acts as the delegate of the audio controller.
@property (nonatomic, weak) id<SINAudioControllerDelegate> delegate
Discussion
The delegate object handles audio related state changes.
See Also
Declared In
SINAudioController.h
– enableSpeaker
required method
Route the call audio through the speaker.
- (void)enableSpeaker
Discussion
Changing the audio route for a call is only possible when the call has been established.
See Also
Declared In
SINAudioController.h
– disableSpeaker
required method
Route the call audio through the handset earpiece.
- (void)disableSpeaker
Discussion
Changing the audio route for a call is only possible when the call has been established.
See Also
Declared In
SINAudioController.h
– startPlayingSoundFile:loop:
required method
Play a sound file, for the purpose of playing ringtones, etc.
- (void)startPlayingSoundFile:(NSString *)path loop:(BOOL)loop
Parameters
path |
Full path for the sound file to play. |
---|---|
loop |
Specifies whether the sound should loop or not. |
Discussion
This is a simple convenience method for playing sounds associated with a call, such as ringtones. It can only play one sound file at a time.
For advanced audio, apps that use the SDK should implement their own methods for playing sounds.
Regardless of whether a sound is looping or not, a corresponding call to the stopPlayingSoundFile method must be done at some point after each invocation of this method.
The sound file must be a mono (1 channel), 16-bit, uncompressed (PCM) .wav file with a sample rate of 8kHz, 16kHz, or 32kHz.
Exceptions
NSInvalidArgumentException |
Throws exception if no file exists at the given path. |
---|
Declared In
SINAudioController.h
– stopPlayingSoundFile
required method
Stop playing the sound file.
- (void)stopPlayingSoundFile
Declared In
SINAudioController.h
– configureAudioSessionForCallKitCall
required method
Configure the audio session for an incoming CallKit call.
- (void)configureAudioSessionForCallKitCall
Discussion
IMPORTANT: this method should be invoked before the CXAnswerCallAction is fulfilled.
Declared In
SINAudioController.h