(This might be a bug in the library, so also filed as a github issue here.)
I would like to detect when react-player fails to play a youtube video due to privacy settings or age restrictions. It seems that sometimes a play failure will result in onError
getting called with error value 150 (corresponding to these sorts of restrictions) but it is not consistent. (See below.)
Is there a recommended way to detect this failure condition?
The following steps show why the onError
callback is insufficient for these purposes:
Go to the react player demo and enter url of a video that is age-restricted (example) or private (example) into the
custom URL
text input, then clickload
. Content heads-up: both examples contain footage from the U.S. Capitol on January 6, 2021; neither load in the player at the time of writing this question.)Check the browser's javascript console. Observe from the console log that
onReady
,onDuration
andonProgress
have fired, butonError
is not present.Now get the URL of a public video (example), enter it into the
custom URL
field and clickload
. Observe the player successfully plays the video.Finally, re-enter the URL of the video in step 2 and press
load
once more. This time, in the javascript console the messageonError 150
appears.
The goal is to get onError
to fire in step 2 (or some equivalently reliable method of failure detection).