feat: loop dial music (#769)

This commit is contained in:
Anton Voylenko
2024-09-17 20:51:01 +03:00
committed by GitHub
parent 7bbfc01cb0
commit c4c5ad33d8

View File

@@ -82,6 +82,8 @@ function filterAndLimit(logger, tasks) {
return unique; return unique;
} }
const sleepFor = (ms) => new Promise((resolve) => setTimeout(() => resolve(), ms));
class TaskDial extends Task { class TaskDial extends Task {
constructor(logger, opts) { constructor(logger, opts) {
super(logger, opts); super(logger, opts);
@@ -203,7 +205,16 @@ class TaskDial extends Task {
else { else {
this.epOther = cs.ep; this.epOther = cs.ep;
if (this.dialMusic && this.epOther && this.epOther.connected) { if (this.dialMusic && this.epOther && this.epOther.connected) {
this.epOther.play(this.dialMusic).catch((err) => {}); (async() => {
do {
try {
await this.epOther.play(this.dialMusic);
} catch (err) {
this.logger.error(err, `TaskDial:exec error playing ${this.dialMusic}`);
await sleepFor(1000);
}
} while (!this.killed || !this.bridged);
})();
} }
} }
if (!this.killed) await this._attemptCalls(cs); if (!this.killed) await this._attemptCalls(cs);