[asterisk-users] ControlPlayback's options

Johan Wilfer lists at jttech.se
Tue May 31 15:20:20 CDT 2011


On 2011-05-30 14:32, virendra bhati wrote:
> Hi List,
>
> Asterisk 's *ControlPlayback* will used for play any recorded file as 
> an audio player. Is it possible that we can use it for multiple 
> forward and rewind ?
>
> ex:-
> original: ControlPlayback(filename,skipms,ff,rew,stop,pause)
> expected 
> ControlPlayback(filename,skip1,skip2,skip3,forward1,rewind1,forward2,rewind2,forward3,rewind3,stop,pause) 
> :

Yes, you can use the CPLAYBACKSTATUS, CPLAYBACKOFFSET and 
CPLAYBACKSTOPKEY variables to get this behavior.
All you have to do is to list the additional keys and stop keys and 
implement this in your dialplan...

I've attached some ael I use for this to implement 1 and 3 as 1 minute 
rewind/forward. 4 and 6 as 5 minutes rewind/forward and 7 and 9 as 15 
minutes.
5 I use as the pause key, and */# to switch recording.

Greetings,
Johan Wilfer

----


   context conference_play_recordings_conference_connect {
     playrec_intro => {
       Set(position=0);
       goto play,1;
     }

     play => {
       while (true) {
         if (${position}==-1) { goto recording_end,1; }

         //rewind 5 seconds after every action (so the user doesn't feel 
lost...)
         Set(position=$[${position}-5000]);
         if (${position} < 0) { Set(position=0); }

         ControlPlayback(${filename},60000,3,1,*#2456790,,,o(${position}));
         Set(position=${CPLAYBACKOFFSET});

         if (${CPLAYBACKSTATUS}==ERROR) {
           Playback(pbx_error_500);
           Playback(pbx_endcall);
           Wait(2);
           Hangup();
         }

         //If stopped by user
         if (${CPLAYBACKSTATUS}==USERSTOPPED) {
           if (!${ISNULL(${CPLAYBACKSTOPKEY})}) { goto 
${CPLAYBACKSTOPKEY},1; }
         }
       }
     }

     recording_end => {
       //The end of the recording is reached
       Set(position=0);
       Background(pbx_endcall);
       WaitExten(2);
       Hangup();
     }

     1 => {
       Set(position=$[${position}-60000]); //Rewind 1 minute
       goto play,1;
     }

     2 => {
       //Instructions, that could be aborted with 2.
       //1 and 3 could be used to forward/rewind 0 ms effectivly 
disabling the defalut..
       ControlPlayback(conf_playrec_instructions_full,0,1,3,2);
       Wait(1);
       goto play,1;
     }

     3 => {
       Set(position=$[${position}+60000]); //Forward 1 minute
       goto play,1;
     }

     4 => {
       Set(position=$[${position}-300000]); //Rewind 5 minutes
       goto play,1;
     }

     5 => {
       goto conference_play_recordings_conference_paused, announce, 1; 
//Pause
     }

     6 => {
       Set(position=$[${position}+300000]); //Forward 5 minutes
       goto play,1;
     }

     7 => {
       Set(position=$[${position}-900000]); //Rewind 15 minutes
       goto play,1;
     }

     9 => {
       Set(position=$[${position}+900000]); //Forward 15 minutes
       goto play,1;
     }

     0 => {
       goto playrec_intro,1; //Restart playback of the current recording
     }

     * => {
       //Previous recording
       //If no recording found, resume playback
       goto play,1;
     }

     # => {
       //Next recording
       //If no recording found, resume playback
       goto play,1;
     }

     i => {
       goto play,1;
     }

   }

   context conference_play_recordings_conference_paused {
     announce => {
       Set(time=$[${epoch_start}+${position}/1000]);
       while(true) {
         WaitExten(1);
         Background(conf_playrec_pause_part1);
         SayUnixTime(${time},${tz},kM);
         Background(conf_playrec_pause_part2);
         SayUnixTime(${time},${tz},d 'digits/of' B);
         Background(conf_playrec_pause_part3);
         WaitExten(5);
       }
     }

     i => {
       //Every inputs goes here
       Wait(1);
       goto conference_play_recordings_conference_connect,play,1;
     }
   }


>
>
> -----
> Thanks and regards
>
>  Virendra Bhati
> +91-9172341457
> Asterisk Engineer
>
>
> --
> _____________________________________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
> New to Asterisk? Join us for a live introductory webinar every Thurs:
>                 http://www.asterisk.org/hello
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>     http://lists.digium.com/mailman/listinfo/asterisk-users


-- 
Med vänlig hälsning

Johan Wilfer                 email: johan at jttech.se
JT Tech | Utvecklare         webb: http://jttech.se
direkt: +46 31 380 91 01  support: +46 31 380 91 00

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20110531/75f990ed/attachment.htm>


More information about the asterisk-users mailing list