file_string is a useful way of specifying multiple sound files to be played or written sequentially. It is a convenience feature.
file_string is implemented by mod_dptools.
The idea behind file_string is simple: when you have multiple sound files to play sequentially, especially when there are many of them, it is convenient to be able to specify all of those files before initiating the playback. In write mode if writing fails, next try are made to the next file in the list
There are two methods of using file_string:
- high level, core most functions that use switch_ivr_playback()
- low level, code that uses direct file handles
You can set up to 128 files in the list.
The high level method works like this:
The low level method works this way:
You may also use this for on hold music:
You can also use it for play_and_get_digits:
Record session failover. If writing fails, it tries the next file:
Note that you have to specify the full path, as sound path expansion is done in switch_ivr_play_file, which is above the level that the file_string:// protocol operates at.
There is a "timeout=" parameter expressed in milliseconds that limits the duration of the file played. This is useful for testing new moh, prompts, etc. audio levels It also allows for more flexible concatenated audio files.
In this example, an extension is made that plays all listed files as follows:
- Announce a number to easily identify the file in the list.
- Play the file for 15 seconds. This is long enough to hear the song and take notes if needed.
An answer is required to prevent the call from timing out so any number of files can be played in a single call.
Without the timeout, you would have to listen to entire files.