[AGI-PHP] Play music while waiting for a download

Hello,
i have already worked with Asterisk AGI-PHP.
I’ve made a beautiful dial plan with php and it work perfectly.
A month ago my server crashed and i’ve lost all, so i’ve try to recreate all but i don’t remember how to do a simply thing.

My plan retrieve data from web (status of an order) and present result as voice.

The main problem is that i want to play music until info is downloaded from web. I can’t use background music because php file of dial plan is dynamic and made by another software.

// Here i want to play music until next stream is reached $data_order = file_get_contents("http://www.website.com/voip/status_order.php?order=".$result['result']); $data_order = json_decode($data_order,true); if ($data_order['status'] == "holded") { $agi->stream_file('/var/lib/asterisk/sounds/nailsatelier/status-ordina-attesa'); }

Hope someone can help me.

Thanks
Claudio