mirror of
https://github.com/justUmen/Bjornulf_custom_nodes.git
synced 2026-03-26 14:48:51 -03:00
0.76
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { api } from '../../../scripts/api.js';
|
||||
import { app } from "../../../scripts/app.js";
|
||||
|
||||
function displayVideoPreview(component, filename, category) {
|
||||
function displayVideoPreview(component, filename, category, autoplay, mute) {
|
||||
let videoWidget = component._videoWidget;
|
||||
if (!videoWidget) {
|
||||
// Create the widget if it doesn't exist
|
||||
@@ -61,6 +61,10 @@ function displayVideoPreview(component, filename, category) {
|
||||
"rand": Math.random().toString().slice(2, 12)
|
||||
};
|
||||
const urlParams = new URLSearchParams(params);
|
||||
if(mute) videoWidget.videoElement.muted = true;
|
||||
else videoWidget.videoElement.muted = false;
|
||||
if(autoplay) videoWidget.videoElement.autoplay = !videoWidget.value.paused && !videoWidget.value.hidden;
|
||||
else videoWidget.videoElement.autoplay = false;
|
||||
videoWidget.videoElement.src = `http://localhost:8188/api/view?${urlParams.toString()}`;
|
||||
|
||||
adjustSize(component); // Adjust the component size
|
||||
@@ -76,8 +80,10 @@ app.registerExtension({
|
||||
async beforeRegisterNodeDef(nodeType, nodeData, appInstance) {
|
||||
if (nodeData?.name == "Bjornulf_VideoPreview") {
|
||||
nodeType.prototype.onExecuted = function (data) {
|
||||
displayVideoPreview(this, data.video[0], data.video[1]);
|
||||
const autoplay = this.widgets.find(w => w.name === "autoplay")?.value ?? false;
|
||||
const mute = this.widgets.find(w => w.name === "mute")?.value ?? true;
|
||||
displayVideoPreview(this, data.video[0], data.video[1], autoplay, mute);
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user