How to stop playback after a fixed time

How can I stop playing an audio after a fixed time and execute the following command in agi script?? $billsec = $agi->get_variable('CDR(duration)',true); $total_min = $agi->get_variable('total_min',true); // $total_min is a local variable $time_to_play = $total_min - $billsec; $agi->exec('Playback','/var/lib/asterisk/sounds/my_file'); //Here I want to set the playback time to $time_to_play

This isn’t a support forum.

You could use a local channel with a time limit.