0

I am setting up a manifest to load a number of images and an audio file that will be played back using SoundJS.

I understand the concept of using createjs.Sound.alternateExtensions to play the supported audio format, but I can't tell if I need to preload both file formats as part of the load manifest. Obviously, this would be undesirable since only one file will be used for playback.

Is it necessary to load both?

manifest = [
{
    src: "./assets/voiceover.mp3",
    id: "vo"
}, {
    src: "./assets/voiceover.ogg",
    id: "vo"
}];

1 Answers1

0

Just specify it once in the list. The "alternateExtensions" list is what SoundJS will try, depending on the current browser support.

For example, if you specify a "file.mp3", and the current browser (eg, Opera) doesn't support mp3, then it will swap out the extension for one it does support. You do not have to specify "file.ogg", it will do that for you.

This approach assumes you have a .ogg file in the same folder as the mp3. If you do not, consider using a complex "src" object, which has full paths to each file.

One note: If you are relying on alternateExtensions, it is recommended to define the file as ".ogg", and put the "mp3" and other extensions as alternates. This is because certain versions of Firefox report that it supports MP3, but will fail. Starting with ogg will get around this.

Lanny
  • 11,244
  • 1
  • 22
  • 30
  • Thank you for the answer. Just one follow up - will the compatible file then be available at run-time, after the preload? Or will it preload the ogg, then have to later retrieve the mp3 if needed? (great tip about starting with ogg; thanks for that) – Craig Rahtz Oct 13 '15 at 23:13
  • It will only preload the first value that it can play. If it can not play it, it will not preload it. Only one file will be preloaded per entry in the manifest. – Lanny Oct 14 '15 at 15:18