Skip to content

OGGs not obtainable in HTML5 even when converted to MP3 #1215

@pkhead

Description

@pkhead

I wrote a custom converter to convert ogg files to mp3, since oggs are not natively supported on HTML5. However, whenever I build the project for HTML5, the resources are not obtainable even though they should have been converted to mp3 files. This is fixed by including the stb_ogg_sound library, in which case the sound files will be obtainable and be converted to mp3 files, but it's a little inconvenient that I have to include that library even though in the end there should be no ogg file processing.

This is the code for my converter:

package convert;

class ConvertOgg2Mp3 extends hxd.fs.Convert {
    function new() {
        super("ogg", "mp3");
    }

    override function convert() {
        var cmd = "ffmpeg";
        var args = ["-hide_banner", "-loglevel", "error", "-i", srcPath, "-ar", "44100", dstPath];
        command(cmd, args);
    }

    // register the convert so that it can be found
    static var _ = hxd.fs.Convert.register(new ConvertOgg2Mp3());

    // used for macro compilation
    public static function doNothing() {}
}

And this is my build.hxml

-cp src
-cp heaps-aseprite/src
-lib heaps
-lib deepnightLibs
-lib ldtk-haxe-api
-lib ase
--main Boot
--debug
-D windowTitle=TEETOEGAME
-D windowSize=1280x720

--macro aseprite.Macros.init()

# Web target
--macro convert.ConvertOgg2Mp3.doNothing()
--macro convert.ConvertWav2Mp3.doNothing()
--js bin/js/game.js
-lib stb_ogg_sound

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions