Skip to content

Commit 459616e

Browse files
authored
soundfile.jump: only jump if currently playing (#404)
- `p5.SoundFile.jump()` should not start playback - Fixes a bug in `p5.SoundFile.reverseBuffer()` where calling that method would trigger playback unexpectedly
1 parent d95d6e4 commit 459616e

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/soundfile.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -903,9 +903,11 @@ define(function (require) {
903903
};
904904

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

931933
/**
@@ -1058,7 +1060,7 @@ define(function (require) {
10581060
// set reversed flag
10591061
this.reversed = !this.reversed;
10601062

1061-
if (currentPos) {
1063+
if (this.isPlaying() && currentPos) {
10621064
this.jump(this.duration() - currentPos);
10631065
}
10641066
this.setVolume(curVol, 0.001);

0 commit comments

Comments
 (0)