40 lines
1.0 KiB
HTML
40 lines
1.0 KiB
HTML
|
<!doctype html>
|
||
|
<html>
|
||
|
<head>
|
||
|
</head>
|
||
|
<body>
|
||
|
<script>
|
||
|
var Module = {
|
||
|
onRuntimeInitialized: function() {
|
||
|
}
|
||
|
};
|
||
|
</script>
|
||
|
<script src="wrapper.js"></script>
|
||
|
<input type="file" id="file" name="file" />
|
||
|
<script>
|
||
|
function onChange(e) {
|
||
|
var file = e.target.files[0];
|
||
|
|
||
|
var reader = new FileReader();
|
||
|
reader.onload = function(e) {
|
||
|
var buffer = reader.result;
|
||
|
var src = new Uint8Array(buffer);
|
||
|
var ptr = Module._malloc(buffer.byteLength);
|
||
|
var arr = new Uint8Array(Module.HEAPU8.buffer, ptr, buffer.byteLength);
|
||
|
arr.set(src, 0);
|
||
|
|
||
|
var stream = new Module.MadStream();
|
||
|
var frame = new Module.MadFrame();
|
||
|
|
||
|
stream.setBuffer(ptr, buffer.byteLength);
|
||
|
frame.decode(stream);
|
||
|
debugger;
|
||
|
}
|
||
|
reader.readAsArrayBuffer(file);
|
||
|
|
||
|
}
|
||
|
document.getElementById("file").addEventListener("change", onChange, false);
|
||
|
</script>
|
||
|
</body>
|
||
|
</html>
|