Skip to content

Commit

Permalink
feat(Video): Handle .play() errors.
Browse files Browse the repository at this point in the history
 - 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.
  • Loading branch information
hristoterezov committed Nov 11, 2024
1 parent 122f5df commit 86d1bd3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion react/features/base/media/components/web/Video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
}
});
}
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const VideoInputPreview = ({ error, localFlipX, track }: IProps) => {
<div className = { classes.container }>
<Video
className = { cx(classes.video, localFlipX && 'flipVideoX') }
id = 'settings_video_input_preview'
playsinline = { true }
videoTrack = {{ jitsiTrack: track }} />
{error && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ const VideoSettingsContent = ({
</div>
<Video
className = { cx(classes.previewVideo, 'flipVideoX') }
id = { `video_settings_preview-${index}` }
playsinline = { true }
videoTrack = {{ jitsiTrack }} />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ class VirtualBackgroundPreview extends PureComponent<IProps, IState> {
return (
<Video
className = { classes.previewVideo }
id = 'virtual_background_preview'
playsinline = { true }
videoTrack = {{ jitsiTrack: data }} />
);
Expand Down

0 comments on commit 86d1bd3

Please sign in to comment.