Audio support: I was wrong

Discussion and feedback on Construct 2

Post » Sun Jul 31, 2011 2:46 pm

Hey all,

In the release notes to r50, I mentioned browser caching is terrible in Firefox and Chrome.

I've done a live test on a real web server and it looks like I was wrong: Firefox and Chrome do actually cache sound files properly, but only when running on a live server. The caching issue looks like a problem with Construct 2's own local HTTP server. It's just that Firefox and Chrome seem to be extremely fussy about the way the server talks to them. As you can imagine C2's own server is not designed to be a full blown internet web server - it's just to serve up some local files - so it does not implement all possible internet server features. This seems to confuse Firefox and Chrome a bit and so they download sound files multiple times. The other browsers aren't bothered and cache anyway.

So, looking at the logs for the local server, I got the impression these browsers were making multiple requests and would do so on the internet as well. Having tested it on the real internet, they seem to cache OK.

They'll keep making multiple requests locally, but it doesn't matter - when just running on your computer, files can be loaded in milliseconds. Nothing is downloaded from the internet.

So, the situation doesn't seem to be as bad as I thought! Chrome can even loop sounds as well, but Firefox still doesn't.

More features can be added but the rest of the HTML5 audio features are still variously supported and unsupported. Still, I could add one or two and see how they work for everyone.

Sound files are still downloaded on first play. I'm actually in favour of keeping it this way, since sound and music can make a large part of a game's download size (especially music). Browsers can stream audio so it can start playing before the whole file has downloaded. This means it's not necessary to leave the user sitting and waiting for all audio to fully download - it can stream it during the game, and the user gets to play the game quicker. This does mean extra latency the first time some sound effects are played, but this seems a small price to pay for a much smaller download. Also, it means sound files which are never played are never downloaded.

For common sound effects I can add a "preload sound" action to download it immediately on startup, so there's no latency on first play. Apart from that, streaming is probably a good idea for the rest.

Sound good?
Scirra Founder
B
359
S
214
G
72
Posts: 22,951
Reputation: 178,578

Post » Sun Jul 31, 2011 3:20 pm

[QUOTE=Ashley]

For common sound effects I can add a "preload sound" action to download it immediately on startup, so there's no latency on first play. Apart from that, streaming is probably a good idea for the rest.

Sound good?[/QUOTE]

---------------------------------------------------


This sounds promising ! ! !
B
19
S
6
G
7
Posts: 1,205
Reputation: 7,298

Post » Sun Jul 31, 2011 5:30 pm

Could the preload sound action have two options: 1, load at startup, and 2, load specifically when the action is called? Then sound loading could be hidden at the start of a level or something. It would give more flexibility.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Sun Jul 31, 2011 5:35 pm

@Arima, you can put a bunch of preload sound actions on "Start of layout" on the first layout (e.g. the menu), or put the actions in some other event. Doesn't that do what you want?Ashley2011-07-31 17:35:42
Scirra Founder
B
359
S
214
G
72
Posts: 22,951
Reputation: 178,578

Post » Sun Jul 31, 2011 5:37 pm

Yeah, that's basically what I meant. I guess I misunderstood, I thought it might be like setting globals where it doesn't matter what event sheet they're on.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Sun Jul 31, 2011 6:18 pm

i just tested support on iphone and its a no go, doesn't play at all,
well seems to play them, but you can't hear it, and it doesn't cache either so there's huge framedrop, i have provided ogg and m4a so i suppose it should work or there's another filetype that should be used, maybe mp3? im waiting for ios5 to retest, hoping for better framerates and soundsupport

testlink - firefox test was very good

testlinkvtrix2011-07-31 18:21:30
ImageImage
B
61
S
19
G
6
Posts: 809
Reputation: 9,028

Post » Sun Jul 31, 2011 6:34 pm

[QUOTE=vtrix]
testlink - firefox test was very good

http://dl.dropbox.com/u/36224287/shooter/index.html[/QUOTE]

I can confirm.


[QUOTE=Ashley]
The caching issue looks like a problem with Construct 2's own local HTTP server. It's just that Firefox and Chrome seem to be extremely fussy about the way the server talks to them. As you can imagine C2's own server is not designed to be a full blown internet web server - it's just to serve up some local files - so it does not implement all possible internet server features. This seems to confuse Firefox and Chrome a bit and so they download sound files multiple times. The other browsers aren't bothered and cache anyway.

[...]

So, the situation doesn't seem to be as bad as I thought! Chrome can even loop sounds as well, but Firefox still doesn't.

More features can be added but the rest of the HTML5 audio features are still variously supported and unsupported. Still, I could add one or two and see how they work for everyone.[/quote]
A good news overall.
By features, you mean pan and volume or are you thinking about more ?

[QUOTE=Ashley]For common sound effects I can add a "preload sound" action to download it immediately on startup, so there's no latency on first play. Apart from that, streaming is probably a good idea for the rest.

Sound good?[/QUOTE]
Sounds really good.Kyatric2011-07-31 18:35:44
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793


Return to Construct 2 General

Who is online

Users browsing this forum: bclikesyou, newt, Ragevortex and 13 guests