Suggestion to allow data URL for audio #1037
Replies: 5 comments
-
wait , unless I'm misunderstanding what you mean, this should be possible, have you seen/tried this : (maybe give me here one example to be sure we are talking about the same thing) |
Beta Was this translation helpful? Give feedback.
-
No, this is not the problem. The problem is that when I load the audio files, it automatically adds a ".mp3" to the end of the URL. This screws up any files which are webpacked into data URLs. Currently audio asset srcs only specify the folder and not the path of the file, as shown in the example on the me.loader page:
I think you should allow the full path to be specified in src so that small audio files can be automatically webpacked into data URLs which will probably load faster. |
Beta Was this translation helpful? Give feedback.
-
oh I see indeed. Well this was implemented this way so that we could ensure that we only (pre)load audio file actually supported by the device (could be .mp3 in one device/browser but ogg on another device/browser), but sure I guess that we could actually specific a full URL with file extension and in that case skip the audio format detection. |
Beta Was this translation helpful? Give feedback.
-
like maybe you can allow an object to specify the format? e.g.
|
Beta Was this translation helpful? Give feedback.
-
not sure when this one was added, but melonJS "now" supports base64 encoded assets, including for audio, see the corresponding test unit : melonJS/tests/browser/spec/loader-spec.js Line 34 in 14941d1 |
Beta Was this translation helpful? Give feedback.
-
Currently, the audio loader is hard-coded to append the name and extension to the path. However, this does not work with data URLs. It is unfortunate because webpack can automatically generate data URLs for small files, and this has to be disabled in order for the audio files to be loaded by melonjs. The behaviour is also inconsistent with that for pictures.
I would like to suggest having the full URL specified for audio files, similar to pictures. If multiple alternative audio formats are needed, an array of alternative URLs may be provided.
Beta Was this translation helpful? Give feedback.
All reactions