Files
2024-05-16 15:34:22 -06:00

20 lines
731 B
JavaScript

import { app } from '../../../scripts/app.js'
import { playSound, appQueueIsEmpty } from './util.js'
app.registerExtension({
name: 'Notifications.PlaySound',
async beforeRegisterNodeDef(nodeType, nodeData, app) {
if (nodeData.name === 'Notif-PlaySound') {
const onExecuted = nodeType.prototype.onExecuted
nodeType.prototype.onExecuted = async function () {
onExecuted?.apply(this, arguments)
if (this.widgets[0].value === 'on empty queue') {
if (!await appQueueIsEmpty(app)) return
}
let file = this.widgets[2].value
playSound(file, this.widgets[1].value)
}
}
},
})