[HTML5] Compressed assets


I have a ton of audio files to download, and downloading them triggers a lot of calls to the server, blocking calls to the services too: is it possible to compress all these files in a single zip and then use them as if I had single files (with an auto-decompression process), available through the Assets library as before?
I can also simply pack the files without compression (mp3 and ogg size hardly goes down), so I can also evaluate alternatives, what I need is to download a single file.

Maybe I could use SWF (right?), but I’d like to avoid that format as much as possible, because one day the servers could block that file format, who knows?

EDIT: I installed the ZIP library and managed to load and extract the bytearray, now I need to convert it to Sound instances:

I tried the newSound.loadCompressedDataFromByteArray way, but doesn’t work.
I also tried the method suggested here, and it works, but I don’t get Sounds, I am getting a js.html.audio.AudioBuffer and not a lime.media.AudioBuffer that I could use to instance a new Sound.

EDIT 2 : loadCompressedDataFromByteArray works, I just have to save the Sound into the Asset cache correctly…


If anyone finds a way of making audio assets work properly for HTML5 using the zip library, it would likely be ideal if we could handle this internally. It would be something for Howler to load our audio from bytes, but the trick is making sure we correctly detect which audio format will work properly for the current browser


I was setting .ogg for audio files to download, but even if I asked for that format, what I was getting (I saw it in the “Network” debug panel of Chrome) was “mp3”: internally Assets.loadSound is deciding what format to download and replacing it in the requested URL, based on format availability I suppose.
I wonder who is deciding for me. If I physically remove the .mp3s, it loads the .oggs, and audio works the same, so at least in Firefox and Chrome the audio format is not a problem, someone should test Safari on iOS and MacOS, and other minor browsers on the main OS.

This would be unnecessary if we found the agent that decides the format for us.

EDIT: I noticed that loadCompressedDataFromByteArray is extremely slow on mobile, I modified the code to read one file at a time to avoid an elaboration flood, but the device hangs anyway for about 3-4 seconds, for a zip of 4.8MB containing 75 files.

On mobile audio files are also affected by a delay of about 1/2 second, that is terrible.
This happens downloading both OGGs and MP3s.