-1

I have an animated HTML Canvas that I produced in Animate cc

The whole thing ran well with all audio playing in sync to the animation.

But I needed to load it from a random point, which I accomplished using the following code:

this.gotoAndPlay(1+Math.random()*3456);

Every animation plays smoothly for the duration of the 5 minute timeline in the published html canvas.

But now none of the sounds are playing except for the one loaded at frame 0

So for example..

this.frame_0 = function() {
    playSound("windy",-1);
}

That is the code which loads the first sound, which is on the same frame as the load a random frame code.

Now if frame 130 is loaded, and the animation plays then the following code

this.frame_143 = function() {
    playSound("TrainSoundwav");
}

Should load the train sound once frame 143 is reached.

But it isn't and none of the other sounds for the entire remainder of the animation are playing in the published canvas.

I've spent hours trying to find a way to play the sounds, but nothing has worked,

Only when I remove the load a random frame code does all the audio work on publish.

I bet it is something simple I am missing,

Please help.

Kaiido
  • 123,334
  • 13
  • 219
  • 285
Magnomic
  • 1
  • 4
  • do you need to rewoke the player ? is there some internal logic which gets harmed ? is the random time to high ? – BlackNetworkBit Sep 11 '18 at 20:11
  • Hi, thank you for your comment. I know the random number isn't too high. And the animations are all still loading exactly as they should. And literally when I take the randomised code out the audio plays as it should. Which has me wondering if the random element is making it lose the frame number, although wouldn't that affect the animation too? – Magnomic Sep 11 '18 at 20:31
  • What other function has the player ? maybe you can pause und play it ? maybe it solves it – BlackNetworkBit Sep 11 '18 at 20:32
  • There is no player, its an animated scene within a html5 canvas, using tweens spread out over 5 minutes (which is why the frame count was so high). So if it was randomly sent to frame 1050 and the plane animation goes on 1053 and the audio is set to play on that frame too... I am seeing the animation, but not hearing the audio. But if I remove the load a random frame code, then at frame 1053 both animation and audio play fine. – Magnomic Sep 11 '18 at 20:36
  • Does this maybe solves your problem : https://forums.adobe.com/thread/1743645 – BlackNetworkBit Sep 11 '18 at 20:38
  • Hey thank you, I have already looked at that. I can't set the audio to stream as it is a html canvas which only allows events. – Magnomic Sep 11 '18 at 20:41

1 Answers1

0

Found a solution...

I swapped the following code...

this.gotoAndPlay(1+Math.random()*3456);

For this code...

this.gotoAndPlay(Math.round(Math.random()* 3456));

Which takes it to random points like the last code, but all the sounds are working now!! (big sigh of relief)

Hopefully this helps anyone stuck in the same bind. :)

Magnomic
  • 1
  • 4