Download custom_nodes/ComfyUI-Custom-Scripts/web/js/playSound.js from vidfom/LTX-5: direct link, hf CLI and curl.
- Browser
- Download file 959 Bytes
-
https://huggingface.co/vidfom/LTX-5/resolve/main/custom_nodes/ComfyUI-Custom-Scripts/web/js/playSound.js
- Command line
-
hf download hf://vidfom/LTX-5/custom_nodes/ComfyUI-Custom-Scripts/web/js/playSound.js
-
curl -L -o playSound.js https://huggingface.co/vidfom/LTX-5/resolve/main/custom_nodes/ComfyUI-Custom-Scripts/web/js/playSound.js
959 Bytes
| import { app } from "../../../scripts/app.js"; | |
| app.registerExtension({ | |
| name: "pysssss.PlaySound", | |
| async beforeRegisterNodeDef(nodeType, nodeData, app) { | |
| if (nodeData.name === "PlaySound|pysssss") { | |
| const onExecuted = nodeType.prototype.onExecuted; | |
| nodeType.prototype.onExecuted = async function () { | |
| onExecuted?.apply(this, arguments); | |
| if (this.widgets[0].value === "on empty queue") { | |
| if (app.ui.lastQueueSize !== 0) { | |
| await new Promise((r) => setTimeout(r, 500)); | |
| } | |
| if (app.ui.lastQueueSize !== 0) { | |
| return; | |
| } | |
| } | |
| let file = this.widgets[2].value; | |
| if (!file) { | |
| file = "notify.mp3"; | |
| } | |
| if (!file.startsWith("http")) { | |
| if (!file.includes("/")) { | |
| file = "assets/" + file; | |
| } | |
| file = new URL(file, import.meta.url) | |
| } | |
| const url = new URL(file); | |
| const audio = new Audio(url); | |
| audio.volume = this.widgets[1].value; | |
| audio.play(); | |
| }; | |
| } | |
| }, | |
| }); | |