Preloading questions

Discussion and feedback on Construct 2

Post » Wed Dec 14, 2011 12:27 am

I am aware of the need to preload audio now. I just have a few questions as to how to go about it.
If I have, say, 30-40 sound effects, what would be the best way to preload them?
I have an 'intro screen' of sorts warning players to use Chrome to play the game which goes for about 7 seconds. Then there is the menu and of course from the menu the game can be accessed. However there are probably about 20 or so sound effects that I know will never be used in the first level and the game always progresses linearly, starting from level 1.

Any suggestions?
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,390

Post » Wed Dec 14, 2011 4:07 pm

I'd say don't preload anything, except maybe the 1 or 2 most commonly played sound effects (e.g. player's gun firing, first explosion sound). There'll be a little bit of latency on some sound effects on the first play, but it probably won't be very noticable if there's no latency on the preloaded gun/explosion/etc. Then, on all subsequent plays the game is cached so everything will play instantly anyway (making the preloads redundant).

There was a bug reported that seemed to be the browser choking if too many sounds were preloaded at once, so I really wouldn't try to preload everything.

So preloads are just really for the first play. I guess you could also preload one or two extra sounds on the start of each level as you progress through the game to keep the latency less noticable.Ashley2011-12-14 16:08:06
Scirra Founder
B
357
S
214
G
72
Posts: 22,946
Reputation: 178,208

Post » Wed Dec 14, 2011 9:11 pm

All right, thanks.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,390

Post » Mon Mar 05, 2012 12:31 am

Sorry to bump but uh..

[QUOTE=Ashley]There'll be a little bit of latency on some sound effects on the first play, but it probably won't be very noticable if there's no latency on the preloaded gun/explosion/etc.[/QUOTE]

It's very noticeable; it often takes ~2 seconds for a sound to play for the first time (if it plays at all) and it does not reflect well on your game. I've tried pre-loading all sounds but it doesn't really help. Do you have to pre-load sounds for each layout or just once at the opening layout?
Image
B
225
S
27
G
13
Posts: 1,774
Reputation: 18,024

Post » Mon Mar 05, 2012 12:54 am

@Tokinsom

An easy way is to add a condition in audio plugin to notice that the track is playable.
B
97
S
22
G
176
Posts: 4,108
Reputation: 103,019

Post » Mon Mar 05, 2012 2:01 am

Just tried pre-loading all the sounds per level, which did the trick! I thought you just had to pre-load them once. Is there any drawback to pre-loading all the sounds/music at the same time? I didn't notice any pauses or anything at the start of the layout so..
Image
B
225
S
27
G
13
Posts: 1,774
Reputation: 18,024

Post » Mon Mar 05, 2012 5:56 am

For music, I remember Ashley told me a while ago not to pre-load it, just stream it. I was having a problem where the music would not play, and then I did what Ashley told me and just streamed it.

I cannot talk for SFX though, as I did not play with those yet.
B
47
S
10
G
6
Posts: 455
Reputation: 8,326

Post » Mon Mar 05, 2012 3:25 pm

You shouldn't really pre-load music because it will stream from the server as it plays anyway, saving bandwidth and allowing the pre-load bandwidth to be used for SFX only. It shouldn't matter if music starts a second or two later.

The Audio object has a global cache for all sounds in all layouts, so I don't know why preloading per-layout would change that at all. Really all you ought to do is set up some pre-loading for the latency-sensitive sounds (explosions, gun fire etc) on the very first layout of your game. Intros or title screens are good for this, e.g. if you flash up your logo for 5 seconds usually the browser can download all your latency sensitive sounds in the background during that, then everything will be ready when the game starts. If you pre-load on start of the game layout itself, and then start trying to play the sounds straight away, they still might not have finished downloading from the preloading, so there's not much point doing that.

In other words, just preload a few things at the very beginning of the game, then try to have 5-10 seconds before the game itself starts, and everything should be ready.

Note this only affects the first run - the second play will load from the disk cache so there will be no delays.
Scirra Founder
B
357
S
214
G
72
Posts: 22,946
Reputation: 178,208


Return to Construct 2 General

Who is online

Users browsing this forum: TheRealDannyyy, Zonacas and 13 guests