in case you want to know, this is what I have for the music-related stuff. window.stopAllSounds()
doesn’t work, but it’s a random attempt I made (i didn’t try that hard at this part)
window.allWickSounds = [];
// WickSound by Jovanny, modified by me to add looping and URL source
window.WickSound = class {
constructor(assetName, loopEnd, loopTime, play = false) {
this.asset = new Howl({
src: [assetName],
autoplay: play
});
//this.asset = project.project.getAssetByName(assetName);
this.loopEnd = loopEnd; // where the loop ends
this.loopTime = loopTime; // milliseconds of looping
this._pan = 0;
this._volume = 1;
this._seek = 0;
this._loop = false;
this._muteVolume = 1;
allWickSounds.push(this);
}
loop(loop) {
if(loop === null || loop === undefined){
return this._loop;
}
this._loop = loop;
this.asset.loop(this._loop);
}
checkLoop() {
if(this.seek() > this.loopEnd) {
this.seek(this.seek() - this.loopTime);
}
}
// Method for volume control, volume = 1 is the default sound volume.
volume(volume) {
if(volume === null || volume === undefined){
return this._volume;
}
this._volume = volume;
if(this._volume<0) {
this._volume = 0;
}else if(this._volume>1) {
this._volume = 1;
}
this.asset.volume(this._volume);
}
// Method for panning pan = -1 all left, pan = 1 all right...
stereo(pan) {
if(pan === null || pan === undefined){
return this._pan;
}
this._pan = pan;
if(this._pan<-1) {
this._pan = -1;
} else if(this._pan>1) {
this._pan = 1;
}
this.asset.stereo(this._pan);
}
// seek sound in seconds from 0 to sound duration
seek(seconds) {
if(seconds === null || seconds === undefined) {
return this.asset.seek();
}
this._seek = seconds;
if(this._seek >this.duration()) {
this._seek = this.duration();
} else if(this._seek<0) {
this._seek = 0;
}
this.asset.seek(this._seek);
}
play(seconds=this.seek()) {
if(!this.isPlaying()) {
this.seek(seconds);
this.asset.play();
}
}
mute() {
this._muteVolume = this._volume;
this.volume(0);
}
unmute() {
this.volume(this._muteVolume);
}
isPlaying() {
return this.asset.playing();
}
stop() {
this.asset.stop();
this.seek(0);
}
pause() {
this.asset.pause();
this._seek = this.currently();
}
currently() {
return this.asset.seek();
}
duration() {
return this.asset.duration();
}
};
window.stopAllSounds = function() {
this.getAssets('Sound').forEach(soundAsset => {
soundAsset.stop();
});
// Stop all sounds on frames
this.getAllFrames().forEach(frame => {
frame.stopSound();
});
allWickSounds.forEach(wSound => {
wSound.stop();
});
};
[...]
window.song = new WickSound("https://media.githubusercontent.com/media/Juan-Cartes/Tetra-Offline/main/Assets/Resources/Music/dance-grid.ogg", 215.63, 162.001, true);