Skip to content

Commit

Permalink
populate audio widget from history
Browse files Browse the repository at this point in the history
  • Loading branch information
huchenlei committed Jun 27, 2024
1 parent e9867a6 commit 9dd50f5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/extensions/core/uploadAudio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,25 @@ app.registerExtension({
const audios = message.audio;
if (!audios) return;
const audio = audios[0];
audioUIWidget.element.src= api.apiURL(getResourceURL(audio.subfolder, audio.filename, "output"));
audioUIWidget.element.src = api.apiURL(getResourceURL(audio.subfolder, audio.filename, "output"));
audioUIWidget.element.classList.remove("empty-audio-widget");
}
}
return { widget: audioUIWidget };
}
}
},
onNodeOutputsUpdated(nodeOutputs: Record<number, any>) {
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") as unknown as DOMWidget<HTMLAudioElement>;
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({
Expand Down
11 changes: 10 additions & 1 deletion src/scripts/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class ComfyApp {
ui: ComfyUI;
logging: ComfyLogging;
extensions: ComfyExtension[];
nodeOutputs: Record<string, any>;
_nodeOutputs: Record<string, any>;
nodePreviewImages: Record<string, typeof Image>;
shiftDown: boolean;
graph: LGraph;
Expand Down Expand Up @@ -116,6 +116,15 @@ export class ComfyApp {
this.shiftDown = false;
}

get nodeOutputs() {
return this._nodeOutputs;
}

set nodeOutputs(value) {
this._nodeOutputs = value;
this.#invokeExtensions("onNodeOutputsUpdated", value);
}

getPreviewFormatParam() {
let preview_format = this.ui.settings.getSettingValue("Comfy.PreviewFormat");
if(preview_format)
Expand Down

0 comments on commit 9dd50f5

Please sign in to comment.