in src/core/awspack/AbstractSpeech.js [63:113]
_createPromise(onFinish, onError, onInterrupt) {
const onResolve = value => {
this._playing = false;
this._speaker.emit(this._speaker.constructor.EVENTS.stop, this);
this._speaker.constructor.emit(
this._speaker.constructor.EVENTS.stop,
this
);
if (typeof onFinish === 'function') {
onFinish(value);
}
};
const onReject = e => {
this._playing = false;
this._speaker.emit(this._speaker.constructor.EVENTS.stop, this);
this._speaker.constructor.emit(
this._speaker.constructor.EVENTS.stop,
this
);
console.error(
`${this.constructor.name} encountered an unexpected error: ${e}`
);
if (typeof onError === 'function') {
onError(e);
}
};
const onCancel = value => {
this._playing = false;
this._speaker.emit(this._speaker.constructor.EVENTS.interrupt, this);
this._speaker.constructor.emit(
this._speaker.constructor.EVENTS.interrupt,
this
);
if (typeof onInterrupt === 'function') {
onInterrupt(value);
}
};
this._promise = new Deferred(undefined, onResolve, onReject, onCancel);
return this._promise;
}