feat: play verb support seekOffset and actionHook (#160)

* feat: play verb support seekOffset and actionHook

* add testcase

* fix: testcase
This commit is contained in:
xquanluu
2022-09-13 13:46:16 +07:00
committed by GitHub
parent e90ef6bc70
commit bf7ece8f17
5 changed files with 60 additions and 10 deletions

View File

@@ -7,6 +7,8 @@ class TaskPlay extends Task {
this.preconditions = TaskPreconditions.Endpoint;
this.url = this.data.url;
this.seekOffset = this.data.seekOffset || -1;
this.timeoutSecs = this.data.timeoutSecs || -1;
this.loop = this.data.loop || 1;
this.earlyMedia = this.data.earlyMedia === true;
}
@@ -31,8 +33,13 @@ class TaskPlay extends Task {
} else {
await this.playToConfMember(this.ep, memberId, confName, confUuid, this.url);
}
} else {
const file = (this.timeoutSecs >= 0 || this.seekOffset >= 0) ?
{file: this.url, seekOffset: this.seekOffset, timeoutSecs: this.timeoutSecs} : this.url;
const result = await ep.play(file);
await this.performAction(Object.assign(result, {reason: 'playCompleted'}),
!(this.parentTask || cs.isConfirmCallSession));
}
else await ep.play(this.url);
}
} catch (err) {
this.logger.info(err, `TaskPlay:exec - error playing ${this.url}`);