Can I customize the error message displayed when React Player cannot play a video?

76 Views Asked by At

I have a use case for React Player (https://www.npmjs.com/package/react-player) where the video that is being displayed from a Cloudfront presigned URL might not exist.

Currently, when the user tries to play the non-existent video, they see the message "No video with supported format and MIME type found."

Is there a way to customize this message in some way, to something like "Please upload a video?"

1

There are 1 best solutions below

0
waleed. On

From the React Player docs

onError - Called when an error occurs whilst attempting to play media

Using that with conditional rendering, you can easily customize the Cloudfront error message.

Here's quick demo I did to show how it works on codesandbox. Play around with it to see how it works.

React Player Demo - Codesandbox