feat(Video): Handle .play() errors.

- Do not throw the error. This results in unhandled rejection promise.
 - Add proper logging so that we can figure out from which video element the error occured.
This commit is contained in:
Hristo Terezov
2024-11-08 17:36:51 -06:00
parent 122f5dffe8
commit 86d1bd3c78
4 changed files with 8 additions and 1 deletions

View File

@@ -239,7 +239,8 @@ class Video extends Component<IProps> {
// Prevent uncaught "DOMException: The play() request was interrupted by a new load request"
// when video playback takes long to start and it starts after the component was unmounted.
if (this._mounted) {
throw error;
logger.error(`Error while trying to play video with id ${
this.props.id} and video track ${this.props.videoTrack?.jitsiTrack}: ${error}`);
}
});
}
@@ -276,6 +277,9 @@ class Video extends Component<IProps> {
this._attachTrack(nextProps.videoTrack).catch((_error: Error) => {
// Ignore the error. We are already logging it.
});
// NOTE: We may want to consider calling .play() explicitly in this case if any issues araise in future.
// For now it seems we are good with the autoplay attribute of the video element.
}
if (this.props.style !== nextProps.style || this.props.className !== nextProps.className) {