allow custom sound
This commit is contained in:
+3
-2
@@ -14,7 +14,8 @@ class PlaySound:
|
||||
return {"required": {
|
||||
"any": (any, {}),
|
||||
"mode": (["always", "on empty queue"], {}),
|
||||
"volume": ("FLOAT", {"min": 0, "max": 1, "step": 0.1, "default": 0.5})
|
||||
"volume": ("FLOAT", {"min": 0, "max": 1, "step": 0.1, "default": 0.5}),
|
||||
"file": ("STRING", { "default": "notify.mp3" })
|
||||
}}
|
||||
|
||||
FUNCTION = "nop"
|
||||
@@ -28,7 +29,7 @@ class PlaySound:
|
||||
def IS_CHANGED(self, **kwargs):
|
||||
return float("NaN")
|
||||
|
||||
def nop(self, any, mode, volume):
|
||||
def nop(self, any, mode, volume, file):
|
||||
return {"ui": {"a": []}, "result": (any,)}
|
||||
|
||||
|
||||
|
||||
+12
-1
@@ -15,7 +15,18 @@ app.registerExtension({
|
||||
return;
|
||||
}
|
||||
}
|
||||
const url = new URL(`assets/notify.mp3`, import.meta.url);
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user