Auto DialOut. audio is played before the call in answered

I am developing an application using Asterisk. In this application, the system calls out automatically using *.call file. And I want to play some audio files when the call is picked up on the other side. But when call goes out, asterisk automatically answer the call and starts playing the audio files. I am using ZAP protocol. While searching on these forums I found a similar problem with suggested sollution at
I have worked on these solutions but all in vain. I have tried using reverse polarity. Then I downloaded nv-linedetect application but could not make it work. So anybody please help me.
Thanks in advance
Atif Majid

Careful where you use such a thing…especially if its going to be used in an outbound dialer situation…the sort of thing is illegal in some countries.

The country where I am going to implement this thing, it is not illegal. So kindly give any solution for this problem.

i think you have a couple of options …

something based … oundDetect that will give you a chance of detecting when the call is answered, or

using hardware (and of course, your telco needs to provide the correct signalling) that supports detection of answering on a Zap channel.

you haven’t said what kind of lines you have, the only hardware i have used that works with answeronpolarityswitch=yes has been the AFT200 from Sangoma.

Thankyou for your reply. I will try to use BackGroundDetect.
I am using Digium TDM400P telephony device which uses FXO and FXS Signalling. Is it possible that we can get this information by using some AGI.