Copy link to clipboard
Copied
I made a demo animation with voice (HTML5 Canvas). I cut each sentence into a sound file, and there were 30 sound files in total. They are placed in sequence on the timeline. Background music plays at the same time, so demo animations can only play a maximum of two sounds at one time. After the release, about 3 sounds did not play, These unplayed sounds were random, and each time a different sound did not play.
1 Correct answer
1. edit the sound in audition to remove sound before the start and after the finish of the desired sound.
2. yes, you can use the soundjs api, SoundJS v1.0.0 API Documentation : SoundJS (createjs.com) which includes play() and stop() methods
Copy link to clipboard
Copied
In addition, 30 sounds are placed in the voice layer and background music is placed in the BGM layer.
Copy link to clipboard
Copied
do all the sounds have their sync property set to stream?
Copy link to clipboard
Copied
Yes. Synchronizing sound and animation.
Copy link to clipboard
Copied
try removing the background sound.
Copy link to clipboard
Copied
Thank you for your method. It's OK after removing the background sound, but what should I do if I need the background sound?
Copy link to clipboard
Copied
try different sync properties for the background sound. it will probably work as an event sound, but i would experiement.
Copy link to clipboard
Copied
After setting the synchronization property of the background sound to "event", the sounds in the voice layer play normally , but encountered more sound related problems, is there an easier way?
If there is no easier way, do you have a link to a web page about the solution?
Sound problems:
1. The background music doesn't play automatically.
2. The background music doesn't loop seamlessly, there's a gap before it starts back again.
3. The background music overlaps.
Copy link to clipboard
Copied
open your background sound in audition and remove white space.
reimport into your fla library and assign a linkage id (eg, soundID).
remove your background sound from the timeline and use:
var sound1 = createjs.Sound.createInstance("soundID");
sound1.addEventListener("complete",completeF);
sound1.play();
function completeF(){
sound1.play();
}
p.s. users will need to interact with your html to start sounds.
Copy link to clipboard
Copied
Sorry, I am not familiar with the script, I do not know how to use the script you provided, I put it in the first frame did not take effect.
After I used the script below, the background music can play, but the background music does not loop. In addition, the stop and pause scripts are not in effect.
Would you help me modify this script? The background music can be played in a loop and can be paused by pressing the button.
var root = this;
root.pauseSound = function()
{
if (root.bgm)
root.bgm.paused = true;
};
root.playSound = function(linkage)
{
if (root.bgm)
{
if (root.bgm.paused)
root.bgm.paused = false;
else
root.sendEvent("stopallsounds");
}
else
{
root.sendEvent("stopallsounds");
root.bgm = createjs.Sound.play(linkage);
}
};
root.stopSound = function()
{
if (root.bgm)
{
root.bgm.stop();
root.bgm = null;
}
};
root.sendEvent = function(name)
{
var event = new CustomEvent(name);
window.parent.document.dispatchEvent(event);
};
root.pause_btn.on("click", function(){ root.sendEvent("pauseallsounds") });
root.play_btn.on("click", function(){ root.playSound("BGM") });
root.stop_btn.on("click", function(){ root.sendEvent("stopallsounds") });
Copy link to clipboard
Copied
did you click your stage or something on stage when testing my code?
Copy link to clipboard
Copied
When I click the Play animation button the background music does not play, the background music starts to play when the animation plays to the voice, so I put a voice file (stream) in the second frame. But there are still two problems that you would like to help me solve?
1. When the background music ends, there is a brief noise before it starts again.
2. The background music is still playing after clicking the pause animation button.
Copy link to clipboard
Copied
does your background music have linkage id = soundID?
Copy link to clipboard
Copied
Yes, the background music have linkage id = soundID.
Copy link to clipboard
Copied
does the sound work here: t (kglad.com)
Copy link to clipboard
Copied
Yes, after I clicked the black button the music played on a loop.
Would you like to send me the file for this example?
I'm sorry that I didn't reply you in time because I received an urgent task recently.
Copy link to clipboard
Copied
the fla contains nothing other than the sound with the linkage id and the black button with the code show in my oct 13 message, kglad.com
Copy link to clipboard
Copied
Thank you very much. After I use your script again, the background music can play normally. But there are the following questions. Would you like to help me again?
1. In the background music loop, noise appears at the moment before the next playback.
2. Is there a way to make the background music play or pause following the play and pause buttons of the animation?
Copy link to clipboard
Copied
1. edit the sound in audition to remove sound before the start and after the finish of the desired sound.
2. yes, you can use the soundjs api, SoundJS v1.0.0 API Documentation : SoundJS (createjs.com) which includes play() and stop() methods
Copy link to clipboard
Copied
Thank you for helping me so much!
Copy link to clipboard
Copied
you're welcome.

