1
votes

I am testing out some simple HTML5 code in order to play embedded YouTube videos in a browser. However, some videos (almost exclusively music videos) will not play in the browser. Instead, a error message stating "This video is unavailable appears" (as shown here).

This is the HTML code used to display the video:

<iframe width="560" height="315" src="https://www.youtube.com/embed/oGpFcHTxjZs" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>

which is the exact code generated by YouTube when selecting their "Embed" option.

The iframe tag does work for some videos, however, as shown here:

<iframe width="560" height="315" src="https://www.youtube.com/embed/jxvPjuREDpE" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>

What is strange is that all types of embedded videos seem to work in an environment such as jsfiddle, but not when loading a separate HTML file into a browser.

A similar issue was asked here: "This video is unavailable" when putting music videos in iFrame , but is only resolved by running an http server, which is a completely new topic to me.

Does anyone know of an HTML/javscript fix to this issue? Thanks in advance.

1

1 Answers

1
votes

I recently came across this as well. An interesting thing that I noticed is that the video becomes unavailable if the origin is not http(s). So try this: create a local file server or upload the html file to somewhere and if you access the file from http protocol, the video will play.