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

Added example for p5.MediaElement.time() #2295

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 44 additions & 1 deletion lib/addons/p5.dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -2112,7 +2112,50 @@
* @method speed
* @param {Number} [speed] speed multiplier for element playback
* @return {Number|Object|p5.MediaElement} current playback speed or p5.MediaElement
*/
*
* @example
* <div><code>
* var ele;
* var beginning = true;
* 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("start at beginning", width/2, height/2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you remove the extra tab here too

* }
*
* 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) {
* if(beginning == true){
* // here we start the sound at the beginning
* // time(0) is not nessisary here
* // as this produces the same result as
* // play()
* ele.play().time(0);
* background(200);
* text("jump 2 sec in", width/2, height/2);
* beginning = false;
* }else{
* // here we jump 2 seconds into the sound
* ele.play().time(2);
* background(250);
* text("start at beginning", width/2, height/2);
* beginning = true;
* }
* }
* }
* </code></div>
*/
p5.MediaElement.prototype.speed = function(val) {
if (typeof val === 'undefined') {
return this.elt.playbackRate;
Expand Down