@anonymous-piwik-user opened this Issue on August 7th 2012

As requested by matt, here's the patch for the Live plugin, which adds sound to the Visitors in real time widget.

There forum thread where this patch originated is here: http://forum.piwik.org/read.php?2,91743

(Apologies if the patch isn't in accordance with the format required by piwik's process, I'm new around here.)

@anonymous-piwik-user commented on August 7th 2012

Attachment: Drop the archive's contents into plugins/Live/templates
PiwikLiveSoundNotifications.zip

@anonymous-piwik-user commented on September 30th 2012

Attachment: Live widget sound notifications. Patch includes sounds and on/off button images.
PiwikLiveSoundWSwitch_patch.zip

@robocoder commented on August 8th 2012 Contributor

There's no license, attribution, or source specified for the .mp3 files.

@mattab commented on August 21st 2012 Member

Thank you for the submission. We definitely would need to use open music released under compatible license.
@organicAnt Can you help sourcing such sounds?

@anonymous-piwik-user commented on August 21st 2012

Sorry for the delay guys. I'm not very familiar with licenses but I chose both Creative Commons sounds.

The click sound notification is licensed under the Creative Commons Attribution License and was sourced from here:
http://www.freesound.org/people/bubaproducer/sounds/107144/

The new visitor sound is an edited version of the last note of the following sound:
http://www.freesound.org/people/Tristan/sounds/19457/

And this is licensed under the Creative Commons 0 License.

You can get more details of the licenses at the links above.

Does this help?

@diosmosis commented on August 26th 2012 Member

Hi organicAnt, matt asked me to take a look at your patch. I don't think it can be applied as is, since the change will likely annoy many existing users. Can you make the following additions to your patch?

  • Playing a sound on a new visit should be disabled by default. For the moment, I think a simple mute button next to the pause & play buttons (see the bottom of plugins/Live/templates/index.tpl) will work. Can you add this?
  • For those who want it, there should be a way to enable the sound by default. The easiest way to do this would be to add a setting to the ini config (config/global.ini.php) and alter the JS in plugins/Live/templates/index.tpl based on the setting's value.

Notes on the patch:

  • The patch should be a diff. If you're using a subversion checkout you can have subversion create one by running 'svn diff' in the root piwik directory. If not, you can use the 'diff' command, but you'll need an unchanged copy of Piwik along w/ your changes.
  • The default value of maxRows shouldn't be changed.
  • Some changes in live.js are unnecessary, such as the change to the line w/ 'if(settings.onUpdate)'. Please remove unnecessary changes from your patch.
  • The calls to console.log(...) should be removed.
  • The fomatting is incorrect, are you using a tab width of 4 spaces?
  • The code you added at the bottom of the file should not be globally accessible, at least not directly through the window object. Can you move it to the top of the '(function($) {' block?

Let me know if you've got any questions. Looking forward to seeing your next patch :)

@anonymous-piwik-user commented on September 30th 2012

Hi capedfuzz,

I've added an on/off sound button and also reworked the play/pause functionality so that now we have a single switch button instead of having separate buttons for pausing/playing.

I'm afraid that I couldn't figure out how to get the audio setting stored as you suggested using global.ini.php (I'm primarily a front end developer).

I created a .diff patch but (being new to svn) I noticed the images and sound files were not included in the patch so I zipped them all with it.

Apologies if the tab width is still wrong, I double checked in Komodo and it is setup to use 4 spaces tabbing (8 pixels wide each tab).

I hope this is somewhat useful and that I didn't forget to include anything. Let me know if otherwise : )

@diosmosis commented on October 18th 2012 Member

Hi organicAnt, here's my review of your new patch:

  • The sound won't play for me. This is because I'm on linux and my browsers won't play mp3 files (though I can play them easily outside the browser). Ideally this should play an .ogg file if the browser supports the ogg format & mp3 if otherwise. If you want to use the HTML5 audio element, this blogpost might help: http://mir.aculo.us/2011/03/16/how-to-play-a-sound-in-a-web-browser-it-aint-easy/
  • The tooltips (and any other text) need to be in the translation file. To do this add keys & values in lang/en.php and use them in the smarty templates using the 'translate' modifier. If you need the translation to be available in the browser, suffix the key w/ '_js' and use _pk_translate('...') in the JS code.
  • To add a new config option, add the config option w/ default value to config/global.ini.php. Then in the appropriate controller method (should be Live.getLastVisitsStart in plugins/Live/Controller.php) set a property on the $view based on the config value (look at how the Piwik_Config class is used). This will make that property visible in the .tpl file so you can vary the html content based on whether the config value was set or not. This is a pretty minor issue, though.

Smaller issues:

  • There's a commented out line in the HTML, this shouldn't be included in the patch. (It's a good idea to review the .diff files yourself first, so you can catch these small issues. If you view the diff file in a editor that can apply syntax highlighting to diff files, reviewing them becomes very easy to do.)
  • The default value for maxRows should not be changed in the patch.
  • The indentation is still off, but I think I know why now. The lines w/ one tab are off by four spaces. I think your text editor is inserting four spaces everytime you use the tab key, but is treating tab characters ("\t") as eight characters wide.
  • In the functions this.onClickToggleUpdate and this.toggleSound, the .attr calls can be chained together (ie, $('...').attr(...).attr(...); )
@mattab commented on December 14th 2012 Member

@organicAnt Did you have a chance to look at the review? we'd love to include your patch in, let us know if you're keen to modify it. Cheers!

@anonymous-piwik-user commented on July 4th 2013

Hi

Interesting plugin. Do you know how this could be configured to play a sound on certain conditions. For example if your visitor had come from a particular campaign or country?

Thanks
Anthony

Replying to organicAnt:

As requested by matt, here's the patch for the Live plugin, which adds sound to the Visitors in real time widget.

There forum thread where this patch originated is here: http://forum.piwik.org/read.php?2,91743

(Apologies if the patch isn't in accordance with the format required by piwik's process, I'm new around here.)

Powered by GitHub Issue Mirror