Files
Amorano-Jovi_Capture/web/node_webcam.js
T
Alexander G. Morano de8653e2ed first pass window capture support
tweaked region support window/monitor
2025-02-22 21:15:13 -05:00

36 lines
995 B
JavaScript

/**
* File: node_webcam.js
* Project: jov_capture
*/
import { app } from "../../../scripts/app.js";
import { api_get } from './util_jov.js'
const _id = "CAMERA (JOV_CAPTURE)";
app.registerExtension({
name: 'jov_capture.node.' + _id,
async beforeRegisterNodeDef(nodeType, nodeData, app) {
if (nodeData.name !== _id) {
return
}
const onNodeCreated = nodeType.prototype.onNodeCreated
nodeType.prototype.onNodeCreated = function () {
const me = onNodeCreated?.apply(this);
const widget_camera = this.widgets.find(w => w.name == 'CAMERA');
this.addWidget('button', 'REFRESH CAMERA LIST', 'refresh', async () => {
var data = await api_get("/jov_capture/camera");
widget_camera.options.values = data;
widget_camera.value = data[0];
app.canvas.setDirty(true);
});
return me;
}
return nodeType;
}
});