Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sound on new visit and on click #3308

Open
anonymous-matomo-user opened this issue Aug 7, 2012 · 10 comments
Open

Add sound on new visit and on click #3308

anonymous-matomo-user opened this issue Aug 7, 2012 · 10 comments
Labels
c: New plugin For features that probably will not be added to Matomo, but could be implemented as plugins. Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.

Comments

@anonymous-matomo-user
Copy link

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-matomo-user
Copy link
Author

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

@robocoder
Copy link
Contributor

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

@mattab
Copy link
Member

mattab commented Aug 21, 2012

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-matomo-user
Copy link
Author

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
Copy link
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-matomo-user
Copy link
Author

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

@anonymous-matomo-user
Copy link
Author

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
Copy link
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
Copy link
Member

mattab commented Dec 14, 2012

@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-matomo-user
Copy link
Author

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.)

@anonymous-matomo-user anonymous-matomo-user added this to the Future releases milestone Jul 8, 2014
@mattab mattab removed the P: normal label Aug 3, 2014
@mattab mattab modified the milestones: Long term, Mid term Dec 23, 2015
@mattab mattab modified the milestones: Long term, Mid term Dec 5, 2016
@Findus23 Findus23 added the c: New plugin For features that probably will not be added to Matomo, but could be implemented as plugins. label Dec 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: New plugin For features that probably will not be added to Matomo, but could be implemented as plugins. Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.
Projects
None yet
Development

No branches or pull requests

5 participants