|
Playing Files |
Top Previous Next |
|
Playing files is a common task in VoIP applications and one of the common questions asked is:
How to play a file to for a caller?
Let suppose our application received an incoming call from a remote party and wants to play a voice menu.
This can be done through the StartPlayFile method:
public void OnInvite(string remoteParty, string callToken) { EndPoint.AcceptCall(callToken); EndPoint.StartPlayFile(callToken, “VoiceMenu.wav”); }
What is the required audio format of VoiceMenu.wav?
Audio files usually used in the Windows world are MP3, OGG or at least stereo 16-bit 44100 Hz PCM files (Audio CD quality). However most speech codecs work with 16-bit 8000 Hz mono audio – that’s a reason why the ASTA SIP SDK works only with this format.
In the future, ASTA SIP may support other formats (if requested by our users) but currently ASTA SIP SDK directly supports PCM 16-bit 8KHz mono files only.
How can such files can be produced?
We recommend the use of
SoX (http://sox.sourceforge.net)
to convert audio files.
This nice utility makes it possible to
How are playing files stopped?
Use the StopPlayFile method.
public void StopMenu(string callID) { EndPoint.StopPlayFile(callID); }
What about a notification when a file has finished playing completely?
Use the OnFilePlayedCompletely event.
This is example of handler:
public void Frm_FilePlayedCompletely(string callToken, string fileName) { EndPoint.StopPlayFile(callToken); }
Why is a method like StopPlayFile call is required?
When a file is played completely – the SDK does not switch to the microphone input by default. It transmits silence to the remote party. StopPlayFile() stops any possible file playing AND switches back to the microphone. If you need to just play another file you don’t need to stop the previous file from playing – just call StartPlayFile() again.
|