Skip to main content
Electric_kindness5C3F
Participant
Juni 2, 2024 11:23 PM UTC
Frage

How to add background music to HTML5 projects that play continuously?

Hey everyone!

 

I'm working on an HTML5 project and I need to add background music that plays independently from the timeline. I've set the sync settings to stream, but the music stops when there is a frame stoppage in the animation. There are also moments where the user clicks a button and returns to earlier moments in the animation and the music plays from that point instead of continuously. I've searched the forums, youtube videos, and support guides but just can't find an answer that works for me. Appreciate any help!

Dieses Thema wurde für Antworten geschlossen.

2 Antworten

nurba
Participating Frequently
Juni 7, 2024 3:59 PM UTC

Hi,

what about playing music through the code?

 

// play music soundtrack on first touch of stage
stage.addEventListener("stagemousedown", playMusic);
 
function playMusic(evt) {
// remove the touch listener not to get triggered again
stage.removeEventListener("stagemousedown", playMusic);
// play music soundtrack
createjs.Sound.play("bgmusic", {
loop: -1
});
}
Übersetzen
kglad
Community Expert
Community Expert
Juni 2, 2024 11:46 PM UTC

use event, not stream 

Übersetzen