Upgrade 3CX to v18 and get it hosted free!

Asterisk cmd ControlPlayback

Author image

Synopsis

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

Description

ControlPlayback(filename[|skipms[|ff[|rew[|stop[|pause[|restart|options]]]]]]])

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
SUCCESS
USERSTOPPED
ERROR
${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).

Example

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):

$AGI->exec(“ControlPlayback”,”$file2play|5000|6|4|#|*|1″);

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


Article Reviews

Write a Review

Your email address will not be published. Required fields are marked *

Required Field. Minimum 5 characters.

Required Field. Minimum 5 characters, maximum 50.

Required field.There is an error with this field.

Required Field.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

There are no reviews for this article. Be the first one to write a review.

Related Posts:

Get 3CX - Absolutely Free!
Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.