[asterisk-users] using Playback() to play a random sound file
Brandon Comouche
brandon at snofalls.com
Thu May 3 08:53:07 MST 2007
I have accomplished a similar outcome that what you are mentioning, but
I use Music on Hold rather than Playback(). Using MOH was a very simple
solution, although I do not know if it is specifically what you are
looking for. This solution allows you to set a time limit on playback as
well as continue to dial extensions. We use the /var/lib/asterisk/sounds
directory and listen to it randomly - can be quite hilarious at times.
To do this, we put a symlink to the sounds directory in the mohmp3
directory and enabled random play. When I want to listen to it use the
following:
----------
[sound-player]
exten => s,1,Answer
exten => s,2,SetMusicOnHold(sounds) ;Name of Music context
exten => s,3,WaitExten(3600|m) ;Wait (for an hour) while listing to the
MOH
exten => s,4,Goto(sound-player,s,2) ;After timeout, start the next hour
;OPTIONAL - Dialing 1 Skips to next audio file
exten => 1,1,SetMusicOnHold(default) ;Change MOH context to drop current
stream (Sometimes I would be placed back on the same music stream, this
seems to reset that)
exten => 1,n,WaitExten(.1|m) ;Play that stream for 1/10 of a second
exten => 1,n,SetMusicOnHold(sounds) ;Reset to what you really want to
hear
exten => 1,n,Goto(custom-music-player,s,3) ;Go to play the MOH sounds
----------
This is actually part of an application that we use as an internal
"radio." Very simple in concept and function, but it randomly plays a
directory full of sound files with the option to "skip" ahead to the
next file. I use variables instead of static contexts though.
I hope this helps you accomplish what you are trying to do.
--
Thanks,
Brandon Comouche
-----Original Message-----
From: asterisk-users-bounces at lists.digium.com
[mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Jay Austad
Sent: Tuesday, May 01, 2007 9:02 PM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: [asterisk-users] using Playback() to play a random sound file
I've got a directory under /var/lib/asterisk/sounds which contains a
bunch of sound files. I would like to call the Playback command to
play the files, but I need it to select a file to play randomly. Is
there any way to do this?
~jay
_______________________________________________
--Bandwidth and Colocation provided by Easynews.com --
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users
More information about the asterisk-users
mailing list