Skip to content

Commit

Permalink
Merge pull request #2467 from bansalnitish/volume
Browse files Browse the repository at this point in the history
Added volume example
  • Loading branch information
lmccart authored Dec 28, 2017
2 parents 207784e + beb263a commit e457148
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/addons/p5.dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -2176,6 +2176,30 @@
* @param {Number} [val] volume between 0.0 and 1.0
* @return {Number|p5.MediaElement} current volume or p5.MediaElement
* @method volume
*
* @example
* <div><code>
* var ele;
* function setup(){
* //p5.MediaElement objects are usually created
* //by calling the createAudio(), createVideo(),
* //and createCapture() functions.
* //In this example we create
* //a new p5.MediaElement via createAudio().
* ele = createAudio('assets/lucky_dragons_-_power_melody.mp3');
* background(250);
* textAlign(CENTER);
* text("Click to Play!", width/2, height/2);
* }
* function mouseClicked() {
* //Here we call the volume() function
* //on the sound element to set its volume
* //Volume must be between 0.0 and 1.0
* ele.volume(0.2)
* ele.play();
* background(200);
* text("You clicked Play!", width/2, height/2);
* }
*/
p5.MediaElement.prototype.volume = function(val) {
if (typeof val === 'undefined') {
Expand Down

0 comments on commit e457148

Please sign in to comment.