Skip to content

Commit

Permalink
soundfile.jump: only jump if currently playing (#404)
Browse files Browse the repository at this point in the history
- `p5.SoundFile.jump()` should not start playback
- Fixes a bug in `p5.SoundFile.reverseBuffer()` where calling that method would trigger playback unexpectedly
  • Loading branch information
therewasaguy authored Jan 6, 2020
1 parent d95d6e4 commit 459616e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/soundfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -903,9 +903,11 @@ define(function (require) {
};

/**
* Move the playhead of the song to a position, in seconds. Start timing
* and playback duration. If none are given, will reset the file to play
* entire duration from start to finish.
* Move the playhead of a soundfile that is currently playing to a
* new position and a new duration, in seconds.
* If none are given, will reset the file to play entire duration
* from start to finish. To set the position of a soundfile that is
* not currently playing, use the `play` or `loop` methods.
*
* @method jump
* @for p5.SoundFile
Expand All @@ -924,8 +926,8 @@ define(function (require) {
var dur = duration || undefined;
if (this.isPlaying()) {
this.stop(0);
this.play(0, this.playbackRate, this.output.gain.value, cTime, dur);
}
this.play(0, this.playbackRate, this.output.gain.value, cTime, dur);
};

/**
Expand Down Expand Up @@ -1058,7 +1060,7 @@ define(function (require) {
// set reversed flag
this.reversed = !this.reversed;

if (currentPos) {
if (this.isPlaying() && currentPos) {
this.jump(this.duration() - currentPos);
}
this.setVolume(curVol, 0.001);
Expand Down

0 comments on commit 459616e

Please sign in to comment.