Merge branch 'MDL-84095-405' of https://github.com/meirzamoodle/moodle into MOODLE_405_STABLE

This commit is contained in:
Huong Nguyen
2025-01-30 10:51:01 +07:00
3 changed files with 30 additions and 2 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -398,6 +398,34 @@ export default class {
this.cleanupStream();
this.requestRecordingStop();
});
this.player.addEventListener('error', this.handlePlayerError.bind(this));
this.player.addEventListener('loadedmetadata', this.handlePlayerLoadedMetadata.bind(this));
}
/**
* Handle the player `error` event.
*
* This event is called when the player throws an error.
*/
handlePlayerError() {
const error = this.player.error;
if (error) {
const message = `An error occurred: ${error.message || 'Unknown error'}. Please try again.`;
addToast(message, {type: error});
// Disable the upload button.
this.setUploadButtonState(false);
}
}
/**
* Handles the event when the player's metadata has been loaded.
*/
handlePlayerLoadedMetadata() {
if (isFinite(this.player.duration)) {
// Note: In Chrome, you need to seek to activate the error listener
// if an issue arises after inserting the recorded audio into the player source.
this.player.currentTime = 0.1;
}
}
/**