mephux/komanda — pull request #136 by AlexKvazos (2014-06-25 09:42:18+00:00)
Title: Sound Notifications

Hey there!
----------

Hello, I have to say that I am so happy to send this pull request. This is the first time I contribute to a GitHub project by adding a new feature. I am used to doing non-significant stuff and such.

This PR implements sound notifications to the client. Komanda does have notifications for OS X however they don't seem to work on when the app is built. I asked some people if it was a good idea to add sounds and it seems like it is.

**Sound Settings**
The sounds can be toggled. I know that most people like to just chill on channels and they don't want to be bugged all the time, so a sounds tab on the settings panel will let you turn off some or all sounds.

![screen shot 2014-06-25 at 4 07 09 am](https://cloud.githubusercontent.com/assets/4448627/3383271/1fa678c4-fc48-11e3-87f2-162424eea5c6.png)
*A screenshot of the sound settings on their default values*

**Testing**
I develop using an OS X machine running Mavericks. This feature should be compatible with any platform supported by node-webkit but do let me know if it doesn't work for you. The client and the sounds work perfectly while using the grunt run task or using the built standalone.

Cheers!

Developers...
------------------------

Adding sounds is dead easy. Let me give you a quick walkthrough of how to do so.

1.- Your sound files should be in `.ogg ` format and should go inside the `app/sounds` folder. Remember its file name.

2.- Go into `main.js` Line #137. This is the function that will add all the sounds into the ionSound plugin. Put the name of your file **WITHOUT** the extension in the sounds array. Followed by a colon and the volume level as a single decimal number. from 1.0 (max) all the way down to 0.0 (min).
![screen shot 2014-06-25 at 4 17 37 am](https://cloud.githubusercontent.com/assets/4448627/3383395/a2291918-fc49-11e3-8d6b-d98333769dc9.png)
*This is how the object looks like as of today Jun 25, 2014*

3.- Now to play any sound just run the following:

$.ionSound.play("sound_name");

"sound_name" should be on the sound array I showed you above. That is pretty much it.

4.- (NOTE) - I added a listener to `main.js` called `"komanda:soundnotification"`. I run this event when messages are sent and here I check if they have that sound enabled to play it or not. This function should be self-explainable.

**Special thanks**
To everyone on the Komanda IRC channel that helped me get RequireJS working. Including the library was somewhat painful. At least I now know how to do it on future contributions.

ionDen's plugin: Ion.Sound
Project can be viewed here: https://github.com/IonDen/ion.sound
Licensed under: **MIT**
The library was modified a little bit so that it would use only ogg files so that it would work with node-webkit.