i am setting up a DISA in asterisk .
what i would like to do is play a music to the caller while asterisk is receiving the DTMF.
the DTMF would stop playing when it receives DTMF for "#"
i have tried using background() and playback() command , but they do not serve the purpose!
You can try using phpagi. There is a function called fastpass_get_data, where you can get dtmf input while playing a sound.
I'm assuming just using the builtin DISA application doesn't meet your needs. If it does, just use that.
There are different ways to program asterisk. You can use normal dialplan, ael dialplan, AGI, AMI, even write your own modules in C.
You can do more things in dialplan, but often using a real language through AGI results in more readable code.
Using the dialplan applications StartMusicOnHold, StopMusicOnHold, and either Read or WaitExten, you should be able to do what you want. Run asterisk -rx 'core show application StartMusicOnHold', etc, to read about each of those.
You basically want to run StartMusicOnHold, then gather digits using Read or WaitExten until you're done (perhaps collecting them into a channel variable), then run StopMusicOnHold.