react-player icon indicating copy to clipboard operation
react-player copied to clipboard

'Video unavailable' when trying to load certain youtube videos

Open james-gulland opened this issue 2 years ago • 3 comments

Be sure to search for your issue before opening a new one.

Current Behavior

Once deployed to heroku, I try and load a youtube video using react-player but it comes back with 'video unavailable - watch on youtube'. On localhost it worked fine.

image

It works OK for some videos, i.e. https://www.youtube.com/watch?v=15Nqbic6HZs&t=1176s&ab_channel=AlfaMist But for most videos, I get the aforementioned error. i.e. https://www.youtube.com/watch?v=Beld090NIoo&t=376s&ab_channel=MyAnalogJournal

Is this something related to copyright for embedded videos?

Expected Behavior

It should load all videos without issue.

Steps to Reproduce

  1. Try and load a video that does not work, i.e. https://www.youtube.com/watch?v=Beld090NIoo&t=376s&ab_channel=MyAnalogJournal - it comes back with 'video unavailable - watch on youtube'
  2. Try and load a video that does work, i.e. https://www.youtube.com/watch?v=15Nqbic6HZs&t=1176s&ab_channel=AlfaMist - it works fine and no error message.

Environment

  • URL attempting to play:
  • An example of a youtube video that does load: https://www.youtube.com/watch?v=15Nqbic6HZs&t=1176s&ab_channel=AlfaMist An example of a youtube video that doesnt load: https://www.youtube.com/watch?v=Beld090NIoo&t=376s&ab_channel=MyAnalogJournal
  • Browser: Chrome latest
  • Operating system: Mac OS Monterey
  • jsFiddle example: https://jsfiddle.net/sv5x3ug1

Other Information

In the console, I do also get the following errors, although not entirely sure if relevant: image

james-gulland avatar Apr 26 '23 16:04 james-gulland

Did you find a solution?

JetShen avatar May 12 '23 23:05 JetShen

Did you find a solution?

yes, I did. Found it here: https://stackoverflow.com/questions/51424578/embed-youtube-code-is-not-working-in-html

By adding SECURE_REFERRER_POLICY = "no-referrer-when-downgrade" it worked after then.

james-gulland avatar May 13 '23 09:05 james-gulland

Just add somewhere in the <head> this

<meta name="referrer" content="no-referrer-when-downgrade">

dennisat avatar Nov 25 '23 17:11 dennisat