Asterisk cmd SetMusicOnHold

Synopsis:

Set default Music On Hold class

Description:

SetMusicOnHold(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.

[context_A]
exten=B,1,SetMusicOnHold(music_B) ; channel A is the active channel, so make it hear music_B
exten=B,1,Dial(SIP/channel_B,M(setmusiconhold,music_A))
exten=C,1,SetMusicOnHold(music_C)
exten=C,1,Dial(SIP/channel_C,M(setmusiconhold,music_A))

[context_B]
exten=A,1,SetMusicOnHold(music_A)
exten=A,1,Dial(SIP/channel_A,M(setmusiconhold,music_B))
exten=C,1,SetMusicOnHold(music_C)
exten=C,1,Dial(SIP/channel_C,M(setmusiconhold,music_B))

[context_C]
exten=B,1,SetMusicOnHold(music_B)
exten=B,1,Dial(SIP/channel_B,M(setmusiconhold,music_C))
exten=C,1,SetMusicOnHold(music_C)
exten=C,1,Dial(SIP/channel_C,M(setmusiconhold,music_C))

[macro-setmusiconhold]
exten=s,1,SetMusicOnHold(${ARG1}) ; channel B is the active channel, so make is hear music_A
exten=s,2,Set(MACRO_RESULT=)


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+

Page Changes | Comments

 

Featured -

Search: