Call Us Today! 877.742.2583




Page tree
Skip to end of metadata
Go to start of metadata

About

Plays a sound file on the current channel.

 

 Click here to expand Table of Contents

Usage

<action application="playback" data="<sound-file-to-play>[@@seek-offset]"/>

sound-file-to-play — sound file in a format that is understood by libsndfile. Path can be relative to the FreeSWITCH™ working directory or fully qualified absolute path to the file.

seek-offset — number of samples to seek into the file to begin playback. This would be useful for a sound file that contained a number of short prompts, to build a phrase from individual words or phonemes. You could also use the 'say' facility for such applications.

Example

<!--default terminator is *. Keyword 'none' disables on-key termination /-->
<action application="set" data="playback_terminators=none"/> 
<action application="playback" data="sounds/soundfile.wav"/>

The terminator used is available in channel variable "playback_terminator_used"

You can also append @@<samples> to the file name to specify a playback start position. This works predictably in PCM files, less predictably with compressed files such as mp3.

playback example
<action application="playback" data="/tmp/test.wav@@8000"/>

Assuming this file was sampled at 8000 samples/second, the @@8000 suffix will seek 1 second into the file and start playback there.

Setting Specific Playback Variables

<action application="playback" data="{var1=val1,var2=val2}sounds/soundfile.wav"/>

The prefix "{var1=val1,var2=val2}" adds specific vars that will be sent in PLAYBACK_START and PLAYBACK_STOP events, this is especially handy when building ESL applications. In the events the variables will be named the same way as the variable names you configured, for instance "var1" and "var2".

Please note that versions older than the commit below, the prefix was instead a suffix set after the filename. So if you experience problems on later versions that you didn't see before, you must upgrade your application to reflect these changes. Also, the events used to prefix the variable names with "playback_variable_", but this is not done anymore.

commit 042347802b2b4972a11212df0c84921b91b71d64
Author: Anthony Minessale <anthm@freeswitch.org>
Date: Wed Feb 20 16:34:13 2013 -0600

Playback from remote server

<action application="playback" data="http://example.com/media/hello_world.wav"/>

Supported File Types

FreeSWITCH has an abstraction layer for file formats. Anyone can write a format module which allows file formats to be utilized from any of the places that would process them.

Most formats support both reading and writing; the ones that do not are identified below.

mod_sndfile

This uses libsndfile and therefore supports any format usable by libsndfile. As of libsndfile-1.0.17, the supported formats are:

  • AIFF (Apple/SGI) (extension "aiff")
  • AU (Sun/NeXT) (extension "au")
  • AVR (Audio Visual Research) (extension "avr")
  • CAF (Apple Core Audio File) (extension "caf")
  • HTK (HMM Tool Kit) (extension "htk")
  • IFF (Amiga IFF/SVX8/SV16) (extension "iff")
  • MAT4 (GNU Octave 2.0 / Matlab 4.2) (extension "mat")
  • MAT5 (GNU Octave 2.1 / Matlab 5.0) (extension "mat")
  • PAF (Ensoniq PARIS) (extension "paf")
  • PVF (Portable Voice Format) (extension "pvf")
  • RAW (header-less) (extension "raw" or "r8" )
  • SD2 (Sound Designer II) (extension "sd2")
  • SDS (Midi Sample Dump Standard) (extension "sds")
  • SF (Berkeley/IRCAM/CARL) (extension "sf")
  • VOC (Creative Labs) (extension "voc")
  • W64 (SoundFoundry WAVE 64) (extension "w64")
  • WAV (Microsoft) (extension "wav")
  • WAV (NIST Sphere) (extension "wav")
  • WAVEX (Microsoft) (extension "wav")
  • XI (FastTracker 2) (extension "xi")

mod_shout

Additionally, mod_shout supplies MP3 support for files and Shoutcast streams.

See Also


2 Comments

  1. Can I use playback a audio file 3 times ?

    Any Example ? Not use for or while in script.

    Thanks.