Asterisk cmd MusicOnHold

Business PBX Solutions
Provider Solution Details
3CX Software PBX for Windows
  • Windows Software Solution
  • Easy to Install and Manage
  • Auto Configures Phones & Trunks
  • Android, iOS, Windows & Mac clients
Details
Bicom VoIP Become an ITSP Now!
  • Become a serious competitor in VoIP Immediately
  • FULL Consultancy, Installation, Training & Support
  • Sell Hosted IP PBXs, Biz Lines, Call Centre
  • Turnkey Provisioning at your data center
Details
Contact Center 4PSA's VoipNow Cloud Communications Platform
  • Enjoy your custom licensing plan - Pay-As-You-Grow!
  • Your fastest go-to-market solution - from deployment to billing.
  • Professional support, training and knowledge base to help you grow your business
  • On your infrastructure or cloud-based, it's up to you.
Details

Synopsis

Play Music On Hold indefinitely.

Description

MusicOnHold([class])

Plays hold music specified by class. If omitted, the default music source for the channel will be used. If you have configured MusicOnHold in musiconhold.conf it will get played automatically if the extension is put on hold. This command FORCES musiconhold music.

The default MusicOnHold class is set with the SetMusicOnHold command (Deprecated in 1.6).

Example

Extension defined in extensions.conf with "forced" MusicOnHold. Remember to Answer before letting the music pour down the line. Otherwise music on hold will not work correctly.
; Answer required as Music On Hold does not answer the call
exten => 6000,1,Answer
exten => 6000,2,MusicOnHold()

It is often useful to turn off music on hold in several situations:
  1. when a particular extension calls (originates)
  2. when connectiong to a particular extension
  3. when traversing a particularly expensive network
  4. when connecting to a conference


(So, how do we do handle each situation?)

You can turn off MOH on a per call by using the SetMusicOnHold command (Deprecated in 1.6).

Add a new class to musiconhold.conf
[none]
mode=files
directory=/dev/null

Create a macro in extensions.conf to turn off MOH
[macro-nomusic]
exten => s,1,NoOp(Turn off MOH for this channel)
exten => s,2,SetMusicOnHold(none)

Now call this macro when you dial an extension
exten => 7020,1,NoOp(Dial -> IAX2/outbound/${EXTEN})
exten => 7020,n,Dial(IAX2/outbound/${EXTEN},,M(nomusic))
exten => 7020,n,Hangup

Asterisk 1.6

MusicOnHold(class[,duration])
Plays hold music specified by class. If class is omitted, the default music source for the channel will be used. Change the default class with Set(CHANNEL(musicclass)=...). If duration is given, hold music will be played specified number of seconds. If duration is ommited, music plays indefinitely.

Returns 0 when done, -1 on hangup.



play-fifo (3rd party addition)

This small C program will create if necessary, open and listen on a fifo for slinear audio and delivers it to STDOUT. If STDOUT is blocking, it discards the data. The idea is that you would use it in a custom class in res_musiconhold. Now you can use whatever means you choose in a seperate process to deliver raw 8khz mono slin to the fifo which will be heard as the music class fifo. An example would be to play your line-in into the fifo and the buffer will not overflow because this program does a poll on the STDOUT and discards STDIN when STDOUT is busy.
You can find it here, it is not part of the Asterisk distribution.

See also



Asterisk | Applications | Functions | Variables | Expressions | Asterisk FAQ

Created by: oej, Last modification: Thu 26 of Jul, 2012 (15:20 UTC) by dlewis7444


Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+

Page Changes | Comments