Adding Audio
Posted: 20 Apr 2015 06:15
Adding audio to triggers and aliases:
It was a happy coincidence to find other threads that ask for the feature that I had also thought of and figured out. The basics of the method is to use links to audio files on the web, create javascript audio objects with them, store them in their own userdata object, and then use the play method on them when the trigger or alias occurs. If you would like to switch them on and off, I'd suggest creating a variable in the music object that holds true or false and checking the state of that variable to figure out whether to play the sound in your trigger.
Here is an example of what my proposed method might look like. Remember, each of these must be set as javascript and not raw code. If you load new sounds to your music object, you must re-run your alias for the music object in order to actually use them otherwise you're going to get an error.
Alias that initializes the music userdata object:
Pattern: load_music
Trigger that plays a sound whenever you receive a newbie (ntell) message:
Pattern: Newbie (regular text is fine here)
Alias to turn the music off:
Pattern: music_off
Alias to turn the music on:
Pattern: music_on
Now, remember, this is only a single music file set for one specific case. However, you can add any file you'd like that you can find online, append it to the list of songs in your music object, and set new triggers for those as well. If you find good sounds, please share them.
It was a happy coincidence to find other threads that ask for the feature that I had also thought of and figured out. The basics of the method is to use links to audio files on the web, create javascript audio objects with them, store them in their own userdata object, and then use the play method on them when the trigger or alias occurs. If you would like to switch them on and off, I'd suggest creating a variable in the music object that holds true or false and checking the state of that variable to figure out whether to play the sound in your trigger.
Here is an example of what my proposed method might look like. Remember, each of these must be set as javascript and not raw code. If you load new sounds to your music object, you must re-run your alias for the music object in order to actually use them otherwise you're going to get an error.
Alias that initializes the music userdata object:
Pattern: load_music
Code: Select all
gwc.userdata.music = {
enabled: 1,
ding:new Audio('http://soundjax.com/reddo/19328%5Eding.mp3')
};
Pattern: Newbie (regular text is fine here)
Code: Select all
if ( gwc.userdata.music.enabled ){
gwc.userdata.music.ding.play();
}
Pattern: music_off
Code: Select all
gwc.userdata.music.enabled = 0;
gwc.output.append("Sound effects OFF");
Pattern: music_on
Code: Select all
gwc.userdata.music.enabled = 1;
gwc.output.append("Sound effects ON");
Now, remember, this is only a single music file set for one specific case. However, you can add any file you'd like that you can find online, append it to the list of songs in your music object, and set new triggers for those as well. If you find good sounds, please share them.