https://qianduan.life
// Node.js主进程中调起子进程
await screen_window();
//function screen_window
import { execFile } from 'child_process';
import path from 'path';
import ipcSend from '../main/utils/ipcSender';
function screen_window() {
return new Promise((resolve, reject) => {
const screen_window = execFile(path.resolve($dirname, '../screenshot/PrintScr.exe'));
screen_window.on('exit', function(code) {
if (code === 1) {
ipcSend.insertImage();
}
resolve();
});
});
}
export default screen_window;
https://github.com/JinJieTan/speex-in-h5
webAssembly
?https://www.wasm.com.cn/demo/Tanks/
,这是坦克!,Unity 教程
中的一个游戏 导出成WebAssembly 的游戏.可是我在国外网站上看到的内容是说:每个WebAssembly线程都在Web Worker中运行,相当于跟JS主解析线程是分开的,不会阻塞JS主线程的解析
https://hacks.mozilla.org/2017/06/a-crash-course-in-memory-management/
WebAssembly.compile(new Uint8Array(`
00 61 73 6d 01 00 00 00 01 0c 02 60 02 7f 7f 01
7f 60 01 7f 01 7f 03 03 02 00 01 07 10 02 03 61
64 64 00 00 06 73 71 75 61 72 65 00 01 0a 13 02
08 00 20 00 20 01 6a 0f 0b 08 00 20 00 20 00 6c
0f 0b`.trim().split(/[\s\r\n]+/g).map(str => parseInt(str, 16))
)).then(module => {
const instance = new WebAssembly.Instance(module)
const { add, square } = instance.exports
console.log('2 + 4 =', add(2, 4))
console.log('3^2 =', square(3))
console.log('(2 + 5)^2 =', square(add(2 + 5)))
})
https://www.wasm.com.cn/getting-started/developers-guide/
<script type="module">
)加载,WebAssembly 目前只能通过 JavaScript 来加载和编译。基础的加载,只需要3步:/**
* @param {String} path wasm 文件路径
* @param {Object} imports 传递到 wasm 代码中的变量
*/
function loadWebAssembly (path, imports = {}) {
return fetch(path)
.then(response => response.arrayBuffer())
.then(buffer => WebAssembly.compile(buffer))
.then(module => {
imports.env = imports.env || {}
// 开辟内存空间
imports.env.memoryBase = imports.env.memoryBase || 0
if (!imports.env.memory) {
imports.env.memory = new WebAssembly.Memory({ initial: 256 })
}
// 创建变量映射表
imports.env.tableBase = imports.env.tableBase || 0
if (!imports.env.table) {
// 在 MVP 版本中 element 只能是 "anyfunc"
imports.env.table = new WebAssembly.Table({ initial: 0, element: 'anyfunc' })
}
// 创建 WebAssembly 实例
return new WebAssembly.Instance(module, imports)
})
}
loadWebAssembly('path/to/math.wasm')
.then(instance => {
const { add, square } = instance.exports
// ...
})
https://zhuanlan.zhihu.com/p/27910351
使用方法:self.importScripts('ffmpeg.js');
onmessage = function(e) {
console.log('ffmpeg_run', ffmpeg_run);
var files = e.data;
console.log(files);
ffmpeg_run({
arguments: ['-i', '/input/' + files[0].name, '-b:v', '64k', '-bufsize', '64k', '-vf', 'showinfo', '-strict', '-2', 'out.mp4'],
files: files,
}, function(results) {
console.log('result',results);
self.postMessage(results[0].data, [results[0].data]);
});
}
Copyright© 2013-2020
All Rights Reserved 京ICP备2023019179号-8