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

#5364 Bugfix : Sound : processSound callback saved and used with loaded + mustPlay #5365

Merged
merged 4 commits into from
Oct 23, 2023
Merged
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
16 changes: 15 additions & 1 deletion src/components/sound.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
autoplay: {default: false},
distanceModel: {default: 'inverse', oneOf: ['linear', 'inverse', 'exponential']},
loop: {default: false},
loopStart: {default: 0},
loopEnd: {default: 0},
maxDistance: {default: 10000},
on: {default: ''},
poolSize: {default: 1},
Expand Down Expand Up @@ -58,6 +60,16 @@
sound.setRolloffFactor(data.rolloffFactor);
}
sound.setLoop(data.loop);
sound.setLoopStart(data.loopStart);

// With a loop start specified without a specified loop end, the end of the loop should be the end of the file
if(data.loopStart != 0 && data.loopEnd == 0){

Check failure on line 66 in src/components/sound.js

View workflow job for this annotation

GitHub Actions / Test Cases (16.x, latest)

Expected space(s) after "if"

Check failure on line 66 in src/components/sound.js

View workflow job for this annotation

GitHub Actions / Test Cases (16.x, latest)

Expected '!==' and instead saw '!='

Check failure on line 66 in src/components/sound.js

View workflow job for this annotation

GitHub Actions / Test Cases (16.x, latest)

Expected '===' and instead saw '=='

Check failure on line 66 in src/components/sound.js

View workflow job for this annotation

GitHub Actions / Test Cases (16.x, latest)

Missing space before opening brace

Check failure on line 66 in src/components/sound.js

View workflow job for this annotation

GitHub Actions / Test Cases (16.x, latest)

Trailing spaces not allowed
sound.setLoopEnd(sound.buffer.duration);
}
else {

Check failure on line 69 in src/components/sound.js

View workflow job for this annotation

GitHub Actions / Test Cases (16.x, latest)

Closing curly brace does not appear on the same line as the subsequent block
sound.setLoopEnd(data.loopEnd);
}

sound.setVolume(data.volume);
sound.isPaused = false;
}
Expand All @@ -80,7 +92,7 @@

// Remove this key from cache, otherwise we can't play it again
THREE.Cache.remove(data.src);
if (self.data.autoplay || self.mustPlay) { self.playSound(); }
if (self.data.autoplay || self.mustPlay) { self.playSound(this.processSound); }
self.el.emit('sound-loaded', self.evtDetail, false);
});
}
Expand Down Expand Up @@ -208,6 +220,7 @@
if (!this.loaded) {
warn('Sound not loaded yet. It will be played once it finished loading');
this.mustPlay = true;
this.processSound = processSound;
return;
}

Expand All @@ -231,6 +244,7 @@
}

this.mustPlay = false;
this.processSound = undefined;
},

/**
Expand Down
Loading