1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. If you had a PIAF Forum account in the vBulletin days, log in with your old credentials. Otherwise, sign up again and we'll get you back in business as soon as we can.
  3. A serious FreePBX vulnerability has been reported. Update your Framework Module immediately. Click here for details.
  4. Critical FreePBX vulnerability! Update your server immediately. Details here.

Streaming MOH / MP3 MOH / Listen to Internet radio by Phone: WORKING

Discussion in 'Add-On Install Instructions' started by tshif, Nov 12, 2008.

  1. tshif Guru

    Updated on August 5 2010 for new version of MPG123 and tested on PBXIAF 1775x)

    I only recently got to start playing with PBXIAF 1.3 (getting ready to upgrade a few 1.0-1.2 versions), and found that most everything just sorta works the way its supposed to.

    :thumbsup: Tom, Ward, Joe - what can we all say but WOW.

    There were just a couple things that seemed a little odd "out of the box" about music on hold, and streaming music on hold.

    A. When we tried uploading our mp3 formatted audio files for MOH, we got the dreaded sh:mpg123 error, and no WAV versions were produced. The MP3 version were listed, and music on hold DID still work. But we prefer the old functionality of having the WAV versions on the list in FreePBX. (This step is STILL desireable on PBXIAF v 1775x - its not there by default.)

    B. The new extra cool streaming music on hold category would not work - period.

    It turns out the solution for both was to install mpg123. After searching around the forums, most of the instructions didn't work, or referenced really old versions of mpg123.

    This procedure gets version 1.8.1-1 of mpg123 which is much newer than other version Ive seen referenced - but I decided to try it anyway.

    Here is what we did to install it:

    Step 1: First install a dependent file:
    Code:
    yum install  libesd.so.0 (This step isn't needed on PBXIAF v 1775x)
    
    Step 2: Second, install mpg123
    Code:
    wget http://apt.sw.be/redhat/9/en/i386/RPMS.dag/mpg123-1.8.1-1.rh9.rf.i386.rpm
      rpm -ivh mpg*.rpm
      rm  mpg123-1.8.1-1.rh9.rf.i386.rpm
      amportal restart
    
    That fixed the MP3 to WAV MOH issue, as well as the streaming MOH. To test that, (using FreePBX 2.5.1) goto MOH, add streaming category. Use a line like this in the APPLICATION field:

    Many users have asked for the ability to listen to streaming internet music on their telephone. To do that - we make the following additional dial plan to [from-internal-custom]:

    Code:
    exten => 69,1,Answer
    exten => 69,2,MusicOnHold(stream)
    exten => 69,3,Hangup
    
    We program a speed dial key on the telephones and label it 'RADIO', which dials ext 69 (change as you see fit), and plays the Streaming MOH - which we so creatively named stream.
    I have been trying to get streaming to work for a long time. I hope that this may help someone in the same situation.

    There is a good reason I didn't talk about using live streams for an actual "Music On Hold" purpose. These techniques should only be used for your personal listening enjoyment in a household setting. Any other use probably breaks laws. Expensive ones.

    Note: I have updated these instructions to reference an even newer mpg123 - that for me suffers way fewer `stream stalls`. If you're doing this for the first time, just follow the directions above. If you are UPDATING from a previous version of mpg123, in step 2 above, instead of doing rpm -ivh mpg*.rpm- use:
    Code:
    rpm -Uvh mpg*.rpm
    
    (Thanks edisoninfo for posting that!)
    The steps outlined in this article produce a very simple ability to listen to streaming music through your phones. See this article for a version that adds user Marv's menu ideas and add the ability to interrupt the menus, and better use of FreePBX extension registrations.


    Good luck!
    Tony
  2. Hat Guru

    I followed your instructions and when I dial 69 I get the stream on my phone. Thanks for the info and the how to. I do have one question, how do I get this or any other stream as my default MOH?:confused5: I can't delete all the original wav files in the default MOH setting of FreePBX. I only get the one remaining file playing.

    Tom

    *Edit* Nevermind, marv's post below did the trick.
  3. marv Member

    A twist on the Music on Hold Streaming

    :crazy: Funny... I was doing pretty much the same thing! But I took a little twist. :eek: After you have all the proper files installed to play, I ran yum -y update and it installed an even newer version of mpg123 1.6.1 along with a few other files. So my part assumes you have the proper files installed to have mpg123 working as above. :cool: Oh yeah, one more thing... my code uses FLITE for text to speech. So search for the install instructions on this site before you proceed. :rolleyes:

    I wanted to be able to select a variety of music instead of just the same channel. :smilewinkgrin: Note the channels I grabbed are just random and not low bitrates, so you may wish to change them.
    Here's my etc/asterisk/musiconhold.com
    [80s]
    mode=custom
    application=/usr/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 http://scfire-mtc-aa04.stream.aol.com:80/stream/1040
    [Hitz]
    mode=custom
    application=/usr/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 http://scfire-dtc-aa02.stream.aol.com:80/stream/1074
    [Jazz]
    mode=custom
    application=/usr/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 http://scfire-ntc-aa10.stream.aol.com:80/stream/1074
    [KickinCountry]
    mode=custom
    application=/usr/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 http://scfire-ntc-aa09.stream.aol.com:80/stream/1075
    [MaxHits]
    mode=custom
    application=/usr/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 http://91.121.201.60:80
    [SwissGroove]
    mode=custom
    application=/usr/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 http://82.197.167.134:80
    [TheEagle-ClassicRock]
    mode=custom
    application=/usr/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 http://64.72.118.64:8030
    [Top40-Christmas]
    mode=custom
    application=/usr/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 http://64.62.194.49:2792
    [default]
    mode=files
    directory=/var/lib/asterisk/mohmp3/
    random=yes
    [none]
    mode=files
    directory=/dev/null


    Then I modified my /etc/asterisk/extensions_custom.conf
    In the [from-internal-custom] section I added:
    exten => 68742,1,Answer
    exten => 68742,2,Flite("After the beep press the number of the music channel you wish to listen to. Or 9 for a list of channels.")
    exten => 68742,3,Read(MusicCode,beep,1)
    exten => 68742,4,GoTo(QueueMusic,s,${MusicCode})
    exten => 68742,5,Hangup

    Then I scrolled to the bottom of the file and added a new section

    [QueueMusic]
    exten => s,1,MusicOnHold(80s)
    exten => s,2,MusicOnHold(Jazz)
    exten => s,3,MusicOnHold(KickinCountry)
    exten => s,4,MusicOnHold(Hitz)
    exten => s,5,MusicOnHold(MaxHits)
    exten => s,6,MusicOnHold(SwissGroove)
    exten => s,7,MusicOnHold(TheEagle-ClassicRock)
    exten => s,8,MusicOnHold(Top40-Christmas)
    exten => s,9,Flite("Press 1 for eighties. 2 for Jazz. 3 for Kickin Country. 4 for Hitz. 5 for Max Hitz. 6 for Swiss Groove. 7 for The Eagle Clasic Rock. 8 for Top 40 Christmas. 9 to hear this list again.")
    exten => s,10,goto(from-internal-custom,68742,2)
    exten => s,11,Hangup

    Then I saved all my files and did an "amportal restart" for the changes to take effect. Now you can dial MUSIC or 68742 and it will ask you which channel you wish to listen to and play that stream. If you wish to change the names and such, just make sure you change them in all places. This is the first time I've ever written anything with asterisk, so feel free to correct me or make improvements. But it's a lot more information and ability than I have been able to find yet. :hurray: No error checking for wrong keys and such, cause I haven't read up that far yet. Maybe one day or someone else.

    So that's my little twist on the Streaming MOH. Of course, after you have done the restart, you can go into your trunk configs and set the MOH option there to whatever streams you wish to use too. :cornut:

    Let me know what ya think! :cheers2:

    -Marv
    - Cool tips like this are available because Ward has been nice enough to setup this board. If you find this useful, drop him some loose change to help him get a better server going ( http://pbxinaflash.com/forum/misc.php?do=donate )
  4. tshif Guru

    Awesome! Its great you posted your mods. It really is a great learning experience (and fun) to see how you handled the tweaks. I love the menu - THANKS for sharing!

    Tony
  5. jroper Guru

    Hi

    I love what you are doing, its a great effort, but one little word of warning before you implement this.

    If you are using internet telephony and streaming music, make sure that you have enough broadband to do both sucessfully, because you don't want so much bandwidth consumed that you cannot make a decent phone call.

    Secondly, In the UK, if you play music on hold, or rebroadbast radio, you have to have a licence as MOH is a public broadcast license. You even have to have one of these if you play the radio at work.

    The same may apply in other countries:-

    http://www.ppluk.com/en/Music-Users/

    The exception to this is the MOH included with Asterisk as that is under the creative commons licence, and you can also find other music released under the creative commons licence, or royalty free music, which often is not of best quality. Ever wondered why music played in Lifts (Elevators) is so cheesy.

    One of my customers had to argue the above point with the authorities, he won.

    Joe
  6. tshif Guru

    Excellent! Glad it worked for you too! I'm gonna try the menu ideas that Marv shared.
  7. tshif Guru

    Joe - so very true what you are saying. They make the software police look almost tame when they come for you for a violation. To all, If your doing this, either use it for home only where its not any form of public rebroadcast. Trust me - err on the side of safety in this issue. Its one reason I didnt include info on how to use this for actual MOH - a place the public (inbound callers) is reasonably expected to be from time to time.
  8. tel0p Guru

    This is very cool. Nice job.

    Not to go OT, but is there a reason why there's like a 30second buffer of streamed music, then it quick-cuts to the live stream? (At least it's doing this for me). Maybe it's a switch on mpg123 I'm missing...
  9. jroper Guru

    I'd go as far as to say even at home, you are on shaky ground if you are using it for Music on Hold, as any member of the public can call you.

    However, I would not envisage any problems using it at home to listen to music though your telephone speakers.

    Joe
  10. marv Member

    How about "This is for educational purposes and use at your own discretion/risk." :gnorsi:

    :idea:Maybe you know of free streams or have setup your own server with advertisements and such. The ideas are endless, this is just a very basic framework which I have not been able to find.

    And if you are using it at home and the "music police" call to check on your system, just hang up... don't put them on hold! :smilewinkgrin:
  11. kenn10 Guru

    Marv -

    One question....how did you determine the streams from the AOL and other channels? When I access AOL from a browser, it pops up its own player and does not seem to give any indication of IP addresses, ports, etc.
  12. marv Member

    That's a good question.

    On some sites such as Shoutcast.com, Sky.FM, and DI.fm will send you a MP3 playlist file. For example, on Sky.FM with Smooth Jazz there are 5 options. From what I have seen, you want a low bitrate MP3 file for better performance (ie low bandwidth usage, but lower quality). Sometimes the URL will give away the format. For example, if you right click on the 24k button on Smooth Jazz you will see the URL http://www.sky.fm/mp3/smoothjazz_low.pls in the properties. That file will be saved in your temporary internet files folder when you click on it to listen to the station. From what I can tell, WMA and AAC+ files are not supported by MPG123. (I may or may not be correct). Inside the PLS file will be anywhere from 1 to many URLs that are used to stream the audio you have selected. I am not familiar with how which stream is selected by the player or how long the URLs in the playlist stay active.

    If you don't want to dig through your temp internet files, you can also just right click on the button and save the file to your desktop. You can even change the extension to .txt for easier opening of it to read.

    You can also setup your own stream server with music, commercials, and such and just direct them to your own internal URL.

    Please note, I used those websites as an example just cause most people are more familiar with them. You can google something like "royalty free stream music" and possibly find other sites too.

    I ran across a few in the wee hours this morning, but forgot to bookmark them. Maybe if someone gets time they can search a few out and share with us all?

    Of course, you can subscribe to a stream and the person you're purchasing it from will supply you with the url, name, and password to utilize.

    Hope that made sense... it's a learning experience for me too.
  13. tshif Guru

    Me to - I haven't figured out if I can make it NOT do that yet. Anyone else?
  14. tshif Guru

    A little Change for Menu Repeat?

    Ok - s,10 confused me, and seemed to behave a little different than I thought. I am not very good with dial plans, but I made these changes, and it seems to allow a repeat of the menu a little easier. Let me know what you think -

    exten => s,10,Read(MusicCode,beep,1)
    exten => s,11,GoTo(QueueMusic,s,${MusicCode})
    exten => s,12,Hangup

    Also, don't forget if you have Cepstral - simply replace all occurrences of "flite" with "swift", and Allison (etc) does the menu for you.

    :party:
  15. marv Member

    I too get that wonderful buffer. Kinda like you get in the car and get to listen to 30 seconds of music before someone else changes the song on ya! LOL!
    If I have another sleepless night, I might try and figure it out. I'm thinking it's a temp file being used as the buffer into asterisk that holds the music. Because if I remember correctly, I was able to reboot my server and the first MOH was the clip from the previous song. I will have to test and verify I wasn't dreaming.
  16. marv Member

    Yeah, I like that. Makes the initial message not repeat, so less waiting! Kudos! :thumbsup:

    :bigear:Question: How can we change it so we can interrupt the listing and press the key wanted instead of having to wait for the beep per say.
  17. bigdog101 New Member

    I have an old version of mpg123 install and the new version will not install. Here is what it says. I'm a linux nubee so please help.

    root@pbx:/usr/src $ rpm -ivh mpg*.rpm
    warning: mpg123-1.3.1-1.rh9.rf.i386.rpm: Header V3 DSA signature: NOKEY, key ID 6b8d79e6
    Preparing... ########################################### [100%]
    file /usr/bin/mpg123 from install of mpg123-1.3.1-1.rh9.rf conflicts with file from package mpg123-0.59r-1

    Please help
  18. edisoninfo Guru

    the -i is for install, instead use a capital U for update

    rpm -Uvh mpg*.rpm
  19. bigdog101 New Member

    Thanks for the fast reply. That did the trick.
  20. edisoninfo Guru

    No problem. Not sure which OS version you have but I believe there is a newer version of mpg123. Something like 1.6.2 or so.

Share This Page