Musiconhold () streaming (DTMF, switching streams)

Hi everyone.

I am trying to work on a solution, where a caller can dial into DID and listen Internet radio streams. He/she should be able to navigate around the streams by entering numbers(1,2,…12,…).

Asterisk version: 1.6.2.18 compile from source
Distribution: CentOS 5.6 (Final)

I searched the forums and Internet but could not find any thing relevant to my problems.

So far, I have been able to make this work but still have problems with the following;

  1. Once musiconhold() app start executing, there is no way to accept user input through DTMF, at least in my knowledge.
  2. I found a solution to problem (1) above In the msiconhold.conf, there is a parameter “digit”
    ;digit=# ; If this option is set for a class, then when callers are listening to music on hold, they can press this digit, and
    ; they will switch to listening to this music class.
    The problem with this is that it only accepts single digit. I am not sure but may be its designed to accept only single digit.
    When I enter two digit number, it either only accepts first digit or select a two digit number randomly.

The bottom line is that I want user to be able to navigate through streams by entering the relevant digit codes. It would be best if I could read user input after musiconhold() starts executing, or any other solution that makes it work.

Here is the snippet of config files.

extensions.conf

[incoming]

exten=>1234,1,Answer()
exten=>1234,2,Wait(2)
exten=>1234,3,Background(Welcomeradio)
exten=>1234,4,WaitExten(,)
exten=>1234,5,NoOp()

exten=>1,1,MusicOnHold(1)
exten=>2,1,MusicOnHold(2)
exten=>3,1,MusicOnHold(3)
exten=>4,1,MusicOnHold(4)
exten=>5,1,MusicOnHold(5)
exten=>6,1,MusicOnHold(6)
exten=>7,1,MusicOnHold(7)
exten=>8,1,MusicOnHold(8)
exten=>9,1,MusicOnHold(9)
exten=>10,1,MusicOnHold(10)
exten=>11,1,MusicOnHold(11)
exten=>12,1,MusicOnHold(12)

exten=>#,1,Background(Welcomeradio)
exten=>#,2,WaitExten()
exten=>#,3,Goto(incoming,5)

exten=>i,1,Goto(incoming,3)
exten=>t,1,hangup()

musiconhold.conf

[1]
mode=custom
application=/usr/local/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 4013.live.streamtheworld.com:80/ARNCITY_SC
digit=1

[2]
mode=custom
application=/usr/local/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 radionri2.lbdns-streamguys.com
digit=2

[3]
mode=custom
application=/usr/local/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 69.162.119.226:8300
digit=3

[4]
mode=custom
application=/usr/local/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 208.186.112.40:8000
digit=4

[5]
mode=custom

application=/usr/local/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 live.apnaradio.com:3232
digit=5

[6]
mode=custom
application=/usr/local/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 -@ provisioning.streamtheworld.com/pls/CHUMFM.pls
digit=6

[7]
mode=custom
application=/usr/local/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 -@ provisioning.streamtheworld.com/ … _DUBAI.pls
digit=7

[8]
mode=custom
application=/usr/local/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 -@ provisioning.streamtheworld.com/ … AI_EYE.pls
digit=8

[9]
mode=custom
application=/usr/local/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 -@ provisioning.streamtheworld.com/pls/DUBAI_92.pls
digit=9

[10]
mode=custom
application=/usr/local/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 -@ provisioning.streamtheworld.com/ … LEEJIA.pls
digit=10

[11]
mode=custom
application=/usr/local/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 -@ provisioning.streamtheworld.com/ … RABIYA.pls
digit=11

[12]
mode=custom
application=/usr/local/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 islam2day.tv:4000
digit=12

Why not change things so that a user presses “1” to escape from the application, and that 1 does a goto into another context with a WaitExten where the user then inputs the stream (now you can do multiple digits) they want to listen to?

Cheers.

Hi Malcom

Thanks for your reply.

Are you referring to escape from musiconhold() app?
Can you tell how we can escape from it?

I think you want StartMusicOnHold ().

Thanks David.
Your suggestion led me to use

exten=>12345,4,WaitExten(,m(1))

and it works perfectly.

Malcom, did you have the similar idea or better? just for knowledge…

very useful scenario, but how can i return to the main welcome message instead of switching the stream??

you can use the Goto statement, and use special keys # or * any other as you desire.

Hi
I am trying to do something like your application.
I am using following to call musiconhold
exten=>1,1,MusicOnHold(1)
exten=>2,1,MusicOnHold(2)

and m using following in musiconhold.conf

[1]
mode=custom
application=/usr/local/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 4013.live.streamtheworld.com:80/ARNCITY_SC
digit=1

[2]
mode=custom
application=/usr/local/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 live.apnaradio.com:3232
digit=2

But I am getting following error:
res_musiconhold.c:538 monmp3thread: Request to schedule in the past?!?!

Do you have any idea what m getting this? Please help me out with this. Thank you.