bvibber/ogv.js

How can I modify the source code so it's possible to load .wasm code not from file?

Opened this issue · 3 comments

I am trying to embed "ogv.js" files into one JS-file, but it seems like I can't load .wasm code not from file.
The generated code for "ogv-demuxer-ogg-wasm.js" contains hardcoded string "ogv-demuxer-ogg-wasm.wasm":
image

Also, I can't find where it comes from (there's no "ogv-demuxer-ogg-wasm.wasm" in the source code anywhere).

I just want to add it to a Tampermonkey script that will replace all <audio> elements with .ogg audio with OGVPlayer.
It's for Safari.

Use the -s SINGLE_FILE=1 option in the emscripten build and modify the Makefile to avoid copying the wasm files. This will increase the size of the javascript package because it has to base64 the wasm.

// If set to 1, embeds all subresources in the emitted file as base64 string
// literals. Embedded subresources may include (but aren't limited to) wasm,
// asm.js, and static memory initialization code.
//
// When using code that depends on this option, your Content Security Policy may
// need to be updated. Specifically, embedding asm.js requires the script-src
// directive to allow 'unsafe-inline', and using a Worker requires the
// child-src directive to allow blob:. If you aren't using Content Security
// Policy, or your CSP header doesn't include either script-src or child-src,
// then you can safely ignore this warning.
// [link]
var SINGLE_FILE = false;

On main branch (work in progress refactoring, so beware it is not stable) you can undo this commit:

d03dce9

to turn single-file mode on, as I was experimenting with it for simplifying packaging.