question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hi, I encountered several issues with the jump function. I don’t know how to format the message nicely as in issue #370, sorry. So:

  • Found a bug
  • Sound
  • Desktop/Laptop

Details about the bug:

  • p5.js version: v0.8.0 April 08, 2019
  • Web browser and version: Firefox 67.0.4 (64 bits)
  • Operating System: Windows 10
  • Steps to reproduce this: 1/ Using
function jumpSong() {
  let songLength = song.duration();
  song.jump(songLength / 2);    // jump to the middle of the song
}

or

function jumpSong() {
song.jump(20);   // jumps forward with 20 secondes
}

1/ New instances of the song are created while song is still playing + 2/ In the console, the song.stop() doesn’t work anymore + 3/ The ‘play/pause’ button is working, but once I click on the ‘jump’ button, the ‘play-pause’ isn’t working anymore, I can click on it, but it won’t pause the song.

I also experienced this:

function jumpSong() {
let songLength = song.duration();
let randomTime = random(songLength);
console.log(randomTime);
song.jump(randomTime);   // jumps to a random moment in the song
}

1/ If I first click the ‘play’ button, and then ‘jump’ button, a new instance of the song adds itself the one playing, but 2/ If I only click on ‘jump’ button, I have 2 times a normal jump, and on the 3rd click a new instance adding itself to the one playing.

Thanks for that wonderful library, very excited to learn it! 😃

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

3reactions
joepdoopercommented, Mar 19, 2020

For the time being (as a workaround) this works for me, both in Firefox and Chrome: after the sound.jump(); function is called use setTimeout(function(){ Object.assign(sound, {_playing: true}); }, 100);

In Safari I still get InvalidStateError: The object is in an invalid state. To get it working in Safari (and Firefox and Chrome) I have the following workaround before the sound.jump(); function:

setTimeout(function(){
  Object.assign(sound, {_playing: true});
  sound.playMode('restart');
}, 100);
sound.stop();
sound.playMode('sustain');
0reactions
joepdoopercommented, Nov 29, 2019

The first time the jump() function is called the sound object has value _playing set to false, but if you run the jump() function again, value _playing is set to true. It toggles between these two values.

Even Object.assign(sound, {_playing: true}) or Object.assign(sound, {_playing: NaN}) will only work on every second time…

The problem seems to be in this small code on line 3161 from p5.sound.js v0.3.11

thisBufferSourceNode._playing = false;

If I remove this, the problem seems to be solved. I don’t know why it is set alternately and not every single time the jump() function is activated…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jump function - Encyclopedia of Mathematics
The function fj is the jump part of f (or jump function of f, using the terminology of Lebesgue [Le]) and it is...
Read more >
Jump statements in C++ - GeeksforGeeks
Jump statements are used to manipulate the flow of the program if some conditions are met. It is used to terminating or continues...
Read more >
Jump Statements in C - Scaler Topics
Jump statements in C are used to interrupt the flow of the program or escape a particular section of the program. There are...
Read more >
7.7 Jump Statements
Jump statements cause an unconditional jump to another statement elsewhere in the code. They are used primarily to interrupt switch statements and loops....
Read more >
Jump Statements - L3HarrisGeospatial.com
Jump statements can be used to modify the behavior of conditional and iterative statements. Jump statements allow you to exit a loop, start...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found