superpowers / superpowers-game

:video_game: Make 2D and 3D games in live collaboration with Superpowers
http://superpowers-html5.com/
Other
402 stars 93 forks source link

[feature] Allow the audio asset to host multiple formats (same as audio tag) #164

Open Ikalou opened 8 years ago

Ikalou commented 8 years ago

Audio is a bit of a mess on the web: different browsers on different platforms support different formats (mp3, ogg, aac...).

Right now, if you care about compatibility, you have to use one asset for each audio format you care about, download all of them on when the game starts (because that's how SP works), and then use feature detection with the DOM (not great) to play the right one.

I was thinking maybe the audio asset could host a variable number of formats (instead of one) and automatically pick and load the first one that's adequate for you. Instead of having a Buffer, it could have an array of {id, buffer, mimeType}. It would need to keep its own nextId and increment it.

At first glance, the scope of files to edit would be:

plugins/default/sound/data/SoundAsset.ts
plugins/default/sound/editors/sound/index.jade
plugins/default/sound/editors/sound/index.ts
plugins/default/sound/editors/sound/index.styl
plugins/default/sound/runtime/sound.ts

Does that sound like the right approach to you? Or would you rather not do it this way?