I am noticing some strange issue with the sound.
On html5 target, if I play a series of sound, one by one, then for some reason the 1st sound I play never stops. But after that, soundchannel.stop() works fine for all other audios playing in series. To ensure it’s not a problem with file itself, I tried replacing various audio files.
Temporarily I solved the issue, by putting a dummy sound file as the first sound. And then calling the next audio after 1 second using Actuate.timer(1). But as I know, this problem was not there in 4.5
hi,
I have exactly the same problem and after 1 full day to change the code in all directions,
I found nothing.
For the first sound, it does not stop but on the other hand it decreases the volume. Even stranger!
I’m going to do the same thing as you, a fake sound of a second waiting for someone to respond.
openfl=5.1.5 & lime=5.2.1
Perhaps we could integrate a fake sound on click for certain platforms, to automate this?
it’s worst than i thought.
I have to play a fake sound and to stop it before it ends although it doesn’t work
`
aideSound = Assets.getSound (“audio/aide.mp3”);
fakeSound = Assets.getSound (“audio/fake.mp3”);
channel = new SoundChannel();
tranformSound = new SoundTransform();
Actuate.timer(.5).onComplete(init);
jouer(fakeSound);
}
private function init() {
channel.stop();
jouer(aideSound);
`
Don’t stop it by listener. As I remember the stop listener code does not work for the 1st sound, which is the main problem. Use a very small sound length. So that it stops automatically.
I got a chance to look into it again. And since it seems there is no way to stop a ghost sound that runs for the first time, I decided not to use channel.stop() at all. Instead I am only making the volume 0 and back to normal instead of using play and stop.
public function playBgMusic(loop_bool: Bool = true): Void
{
if (bgchannel == null)
{
if (loop_bool)
{
bgchannel = bgMusic_Snd.play(0, 9999, new SoundTransform(0.25, 0));
}
else
{
bgchannel = bgMusic_Snd.play(0, 1, new SoundTransform(0, 0));
}
}
else
{
bgchannel.soundTransform = new SoundTransform(0.25);
}
}
public function pauseBgMusic ( ):Void
{
if ( bgchannel != null)
{
bgchannel.soundTransform = new SoundTransform(0);
}
}