Asterisk cmd SetMusicOnHold


Set default Music On Hold class



Sets the default class for music on hold for a given channel. When music on hold is activated, this class will be used to select which music is played.

NOTE: This sets what music the perticular channel will hear. Example:
  • Channel A calls extension for channel B
  • The dialplan executes SetMusicOnHold(music_A)
  • The dialplan Dials channel B, channel B answers and the call is bridged.
  • Channel B puts channel A on hold: channel A hears "music_A" hold music.
  • Channel A puts channel B on hold: channel B hears default hold music (which may or may not be "default" depending on your musiconhold.conf and channel conf file settings).

To set the music on hold for the channel that is being dialed, you must use the M (macro) flag from the Dial command.

exten=B,1,SetMusicOnHold(music_B) ; channel A is the active channel, so make it hear music_B



exten=s,1,SetMusicOnHold(${ARG1}) ; channel B is the active channel, so make is hear music_A

This may seem backwards, however, if you remember that SetMusicOnHold sets the music that the active channel will hear, and not the music that it will play, that should help alleviate any confusion. In the example above, you want channel A to hear the music of channel B (music_B) and you want channel B to hear channel A's music (music A). So, when channel A puts channel B on hold, channel B hears channel A's hold music.

New in Asterisk 1.6

SetMusicOnHold is now deprecated. You should use Set(CHANNEL(musicclass)=...) instead.

See also

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

Created by: oej, Last modification: Wed 02 of Apr, 2008 (12:58 UTC) by manuna
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+