Kagami / vmsg

:musical_note: Library for creating voice messages
https://kagami.github.io/vmsg/
Creative Commons Zero v1.0 Universal
348 stars 58 forks source link

Non React demo #14

Closed octavn closed 6 years ago

octavn commented 6 years ago

All 3 demos are React based. Would love to see a non React demo or better documentation around using vmsg in a plain HTML/JS app.

Kagami commented 6 years ago

What about Usage example? It's plain JS, just bind vmsg.record call to any button and it should work.

octavn commented 6 years ago

For example I am trying to load the vmsg.wasm using:

var importObject = {};
WebAssembly.instantiateStreaming(fetch('https://cdn.rawgit.com/Kagami/vmsg/df671f6b/vmsg.wasm'), importObject).then(
 obj => obj.instance.exports.record()
);

and I get the following error in Chrome:

Uncaught (in promise) TypeError: WebAssembly Instantiation: Import #0 module="env" error: module is not an object or function

If I remove importObject I get

Uncaught (in promise) TypeError: WebAssembly Instantiation: Imports argument must be present and must be an object
Kagami commented 6 years ago

You shouldn't load vmsg.wasm directly. Use the JS library instead.

octavn commented 6 years ago

In that case you should update this line in readme.md under Usage:

Don't forget to include vmsg.css and vmsg.wasm in your project.

Kagami commented 6 years ago

It means you need to just host vmsg.wasm, it should be available as /static/js/vmsg.wasm URL by default. vmsg JS library will load that file for you.

octavn commented 6 years ago

I've managed to get a plain JS/HTML non React demo up and running. I will publish my code soon.

octavn commented 6 years ago

I've created a plain JS/HTML demo at https://github.com/addpipe/simple-vmsg-demo

Live demo: https://addpipe.com/simple-vmsg-demo/

Since I deal a lot with audio recording I've also covered vmsg in more detail in this article https://addpipe.com/blog/recording-mp3-audio-in-html5-using-vmsg-a-webassembly-library-based-on-lame/

Kagami commented 6 years ago

Thanks.

Kagami commented 6 years ago

Added it to readme.