Skip to content

Commit

Permalink
Merge pull request #2225 from bomoko/Documentation/MediaElement_src_docs
Browse files Browse the repository at this point in the history
Added p5.MediaElement.src example
  • Loading branch information
lmccart authored Oct 1, 2017
2 parents cb91691 + 0f149c4 commit f748178
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions lib/addons/p5.dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -1752,6 +1752,40 @@
*
* @property src
* @return {String} src
* @example
* <div><code>
* var ele;
*
* function setup() {
* background(250);
*
* //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/beat.mp3');
*
* //We'll set up our example so that
* //when you click on the text,
* //an alert box displays the MediaElement's
* //src field.
* textAlign(CENTER);
* text("Click Me!", width/2, height/2);
* }
*
* function mouseClicked() {
* //here we test if the mouse is over the
* //canvas element when it's clicked
* if(mouseX >= 0 && mouseX <= width &&
* mouseY >= 0 && mouseY <= height) {
* //Show our p5.MediaElement's src field
* alert(ele.src);
* }
* }
*
* </code></div>
*/
Object.defineProperty(self, 'src', {
get: function() {
Expand Down

0 comments on commit f748178

Please sign in to comment.