Function init

  • Initialize and configure the audio support.
    For a maximum browser coverage the recommendation is to use at least two of them, typically default to webm and then fallback to mp3 for the best balance of small filesize and high quality, webm has nearly full browser coverage with a great combination of compression and quality, and mp3 will fallback gracefully for other browsers. It is important to remember that melonJS selects the first compatible sound based on the list of extensions and given order passed here. So if you want webm to be used before mp3, you need to put the audio format in that order.

    Parameters

    • Optionalformat: string = "mp3"

      audio format to prioritize ("mp3"|"mpeg"|"opus"|"ogg"|"oga"|"wav"|"aac"|"caf"|"m4a"|"m4b"|"mp4"|"weba"|"webm"|"dolby"|"flac")

    Returns boolean

    Indicates whether audio initialization was successful

    // initialize the "sound engine", giving "webm" as default desired audio format, and "mp3" as a fallback
    if (!me.audio.init("webm,mp3")) {
    alert("Sorry but your browser does not support html 5 audio !");
    return;
    }