Jay Austad
2007-May-01 21:01 UTC
[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
Steve Edwards
2007-May-01 21:10 UTC
[asterisk-users] using Playback() to play a random sound file
On Tue, 1 May 2007, Jay Austad wrote:> 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?I do this with an AGI. Thanks in advance, ------------------------------------------------------------------------ Steve Edwards sedwards@sedwards.com Voice: +1-760-468-3867 PST Newline Fax: +1-760-731-3000
Steve Finkelstein
2007-May-02 07:47 UTC
[asterisk-users] using Playback() to play a random sound file
Unless there is some native rand() function available in Asterisk, I'd look into writing a simple AGI using Perl, PHP or Python to return back a random file to Playback(). More information here: http://www.voip-info.org/wiki-Asterisk+AGI HTH - sf Jay Austad wrote:> 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 > > !DSPAM:1020,46380d8a549331644115261! >
Brandon Comouche
2007-May-03 08:53 UTC
[asterisk-users] using Playback() to play a random sound file
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@lists.digium.com [mailto:asterisk-users-bounces@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