Closed ivangusev closed 1 year ago
Oh! Yes, this seems to be a legacy code error that has been corrected and will be fixed on 0.0.21.
@Vinlic, thanks for the fix, and what about catching the error?
Now you can listen for errors through the "error" event. :D
@Vinlic , unfortunately i can't confirm. If you just replace reject() with "throw" it's not enough, because in Audio.js load() you return a promise. So you need to handle when it's rejected.
@ivangusev This rejected promise will eventually be captured by the global asynchronous method in the Synthesizer.start() function and passed through _emitError(err) thrown to your listening callback function. Synthesizer.js
...
start() {
...
(async () => {
...
await this.#waitForAudiosLoaded(); // Waiting for all audio to load here.
...
})()
.catch(err => this._emitError(err)); // Will notify you of the error here
}
...
@Vinlic , i think it's not the only place where it's called. I'm adding audio like this:
const video = wvc.createSingleVideo({
content: content,
pageWaitForOptions: {
waitUntil:'networkidle0'
}
...
});
video.on("error", (err) => {
console.error(err);
});
video.addAudio({
url: req.body.mp3,
));
await video.startAndWait();
And error is not captured. Synthesizer.start() is not even reached to the time of error.
@ivangusev
I understand now. In the addAudio
function, I added audio.load()
, which triggers preloading when adding audio. Now I may consider removing it or changing it to audio.load().catch(err => this._emitError(err))
(which will trigger two error events)
@Vinlic , yes, that's what i meant: audio.load().catch(err => this._emitError(err))
@ivangusev I have made changes and this update will be included in the next release version. :D
If we pass non-mp3 (jpeg for example) we get "ReferenceError: reject is not defined" in checkRemoteResource() Also please handle the case of rejected promise in Audio.js load(), otherwise the whole application is crashed without catching the error. Ideally i should get this error in: