Asterisk cmd ControlPlayback


Plays a sound file with fast forward, rewind and stop controls.



Note: New version Asterisk (about 1.6 above), the Optional Parameters separated by the , character not |

This application will play back the given filename (do not include the filename extension). By default, the * key can be used to rewind, and the # key can be used to fast-forward.

Optional Parameters:
  • skipms - This is number of milliseconds to skip when rewinding or fast-forwarding.
  • ff - Fast-forward when this DTMF digit is received.
  • rew - Rewind when this DTMF digit is received.
  • stop - Stop playback when this DTMF digit is received.
  • pause - Pause playback when this DTMF digit is received.
  • restart - Restart playback when this DTMF digit is received.
  • Options: At present the only valid option is j - Jump to priority n+101 if the requested file is not found.
In new version: Options: o(time): time - Start at <time> ms from the beginning of the file.

This application sets the CPLAYBACKSTATUS channel variable upon completion. The CPLAYBACKSTATUS variable will contain the status of the attempt as a text string, one of: SUCCESS | USERSTOPPED | ERROR

New version Controlplayback
This application will play back the given <filename>.
It sets the following channel variables upon completion:
${CPLAYBACKSTATUS}: Contains the status of the attempt as a text string
${CPLAYBACKOFFSET}: Contains the offset in ms into the file where playback
was at when it stopped. '-1' is end of file.
${CPLAYBACKSTOPKEY}: If the playback is stopped by the user this variable
contains the key that was pressed.

The caller may control the playback of the sound by dialing the forward button (default is *) and the rewind button (default is #). Each press of these keys will skip the playback skip milliseconds forward or backward as appropriate. You may also specify stop, restart and pause buttons.

Note that as the * key is on the left and the # button is on the right of a telephone keypad, it may make more sense to swap the default buttons: use * for rewind and # for forward.

Return Code

Returns -1 on hangup or if filename doesn't exist, 0 otherwise (this may have been true in the past, don't know if it is still the case).


exten => 1234,1,ControlPlayback(mysoundfile,4000,*,#,1,0)

NOTE that if ControlPlayback is called using AGI then the options must be separated by the | character rather than a comma. Example (from a Perl script, where the filename to play back was stored in variable $file2play):


In this example, 6 was used to go forward 5 seconds, and 4 to go back 5 seconds (emulating the positions of the forward and back buttons on many remote controls). # stops the playback and * pauses it, while 1 restarts from the beginning (from the "1st" part of the recording).

See also

Asterisk | Applications | Functions | Variables | Expressions | Asterisk FAQ

Created by: JustRumours, Last modification: Thu 27 of Sep, 2012 (04:32 UTC) by dominic16y
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+