Populate audio widget when load history

This commit is contained in:
huchenlei 2024-06-26 23:36:13 -04:00
parent e2b7182648
commit c87e69a27a
2 changed files with 22 additions and 2 deletions

View File

@ -111,7 +111,18 @@ app.registerExtension({
return { widget: audioUIWidget } return { widget: audioUIWidget }
} }
} }
} },
onNodeOutputsUpdated(nodeOutputs) {
for (const [nodeId, output] of Object.entries(nodeOutputs)) {
const node = app.graph.getNodeById(Number.parseInt(nodeId));
if ("audio" in output) {
const audioUIWidget = node.widgets.find((w) => w.name === "audioUI");
const audio = output.audio[0];
audioUIWidget.element.src = api.apiURL(getResourceURL(audio.subfolder, audio.filename, "output"));
audioUIWidget.element.classList.remove("empty-audio-widget");
}
}
},
}) })
app.registerExtension({ app.registerExtension({

View File

@ -71,7 +71,7 @@ export class ComfyApp {
* Stores the execution output data for each node * Stores the execution output data for each node
* @type {Record<string, any>} * @type {Record<string, any>}
*/ */
this.nodeOutputs = {}; this._nodeOutputs = {};
/** /**
* Stores the preview image data for each node * Stores the preview image data for each node
@ -86,6 +86,15 @@ export class ComfyApp {
this.shiftDown = false; this.shiftDown = false;
} }
get nodeOutputs() {
return this._nodeOutputs;
}
set nodeOutputs(value) {
this._nodeOutputs = value;
this.#invokeExtensions("onNodeOutputsUpdated", value);
}
getPreviewFormatParam() { getPreviewFormatParam() {
let preview_format = this.ui.settings.getSettingValue("Comfy.PreviewFormat"); let preview_format = this.ui.settings.getSettingValue("Comfy.PreviewFormat");
if(preview_format) if(preview_format)