Embeded youtube video error - html

I'm trying to embed a youtube video on my site and no matter what video I embed it just says "an error has occurred." (This is the clearly explained problem)
I would like for the video to work. (This is the desired outcome)
<iframe width="420" height="315" src="https://www.youtube.com/embed/watch?v=039nv45oth8"></iframe>
(The above is the minimum needed code)

Try this code instead:
<iframe width="420" height="315" src="https://www.youtube.com/embed/039nv45oth8" frameborder="0" allowfullscreen></iframe>

Actually you don't have to write your code by yourself, just go to the video you want to add it in YouTube, then click the button "SHARE" , select "Embed" and you see the code is ready. Just copy it by clicking "COPY" then paste it in your html code.

Related

Why does YouTube Player API show "This video is unavailable." when playing certain videos?

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.
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.

How to control youtube embed live stream?

I have just learned that YouTube live stream URL is randomly changing. I found this on stackoverflow "YouTube Live Streaming embed code keeps changing"
so I know the the static embed link is this https://www.youtube.com/embed/live_stream?channel=[channel ID]
What I would like know is how to add autoplay=1 to the embed link and any other functions like this.
30/7/2017 Update - this method does not work on ios V10.3.3 tested on an iPhone 6+ the player crashes safari and chrome !
It's really simple, just add the parameter autoplay=1 at the end:
https://www.youtube.com/embed/live_stream?channel=[channel ID]&autoplay=1
allow autoplay and add it to the end of the embed src.
<iframe width="560" height="315" src="https://www.youtube.com/embed/ldy3VEPIRk0?autoplay=1" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>

Embed YouTube video - Refused to display in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN' [duplicate]

This question already has answers here:
Embedding youtube video "Refused to display document because display forbidden by X-Frame-Options"
(10 answers)
Closed 5 years ago.
I am trying to feed my Django page with some resource I am getting from somewhere else.
Inside the feed, I have YouTube videos with URL like: https://www.youtube.com/watch?v=A6XUVjK9W4o
Once I added this into my page, the video does not show up, saying:
Refused to display 'https://www.youtube.com/watch?v=A6XUVjK9W4o' in a
frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.
Then I said, well, what if I change watch to embed. Then YouTube player shows up, but no video, saying:
How can I get this to work?
I am showing it in HTML like this:
<iframe width="420" height="315"
src="{{vid.yt_url}}">
</iframe>
I googled almost for an hour, but no sign of success. I tried to append &output=embed - nada...
You must ensure the URL contains embed rather watch as the /embed endpoint allows outside requests, whereas the /watch endpoint does not.
<iframe width="420" height="315" src="https://www.youtube.com/embed/A6XUVjK9W4o" frameborder="0" allowfullscreen></iframe>
The YouTube URL in src must have and use the embed endpoint instead of watch, so for instance let’s say you want to embed this YouTube video: https://www.youtube.com/watch?v=P6N9782MzFQ (browser's URL).
You should use the embed endpoint, so the URL now should be something like https://www.youtube.com/embed/P6N9782MzFQ. Use this value as the URL in the src attribute inside the iframe tag in your HTML code, for example:
<iframe width="853" height="480" src="https://www.youtube.com/embed/P6N9782MzFQ" frameborder="0" allowfullscreen ng-show="showvideo"></iframe>
So just replace https://www.youtube.com/watch?v= with https://www.youtube.com/embed/ and of course check for your video's ID. In this sample, my video ID is P6N9782MzFQ.
You only need to copy <iframe> from the YouTube Embed section (click on SHARE below the video and then EMBED and copy the entire iframe).
If embed no longer works for you, try with /v instead:
<iframe width="420" height="315" src="https://www.youtube.com/v/A6XUVjK9W4o" frameborder="0" allowfullscreen></iframe>
Along with the embed, I also had to install the Google Cast extension in my browser.
<iframe width="1280" height="720" src="https://www.youtube.com/embed/4u856utdR94" frameborder="0" allowfullscreen></iframe>

html : iframe not showing content in html

I want to show a youtube video in html 4. For that, I am using iframe. But the content of iframe is not showing.
<iframe frameborder="1" width="420" height="345" src="https://www.youtube.com/watch?v=C8kSrkz8Hz8"></iframe>
FYI: I am using Firefox 29.0 and Chrome 35.0. Both browsers are showing the same result.
Change your src with //www.youtube.com/embed/C8kSrkz8Hz8
your code shoud look like this
<iframe frameborder="1" width="420" height="345" src="//www.youtube.com/embed/C8kSrkz8Hz8"></iframe>
Find code under each video on youtoube at Share menu.
When you try to put the whole YouTube page into an iframe, it sends a HTTP header called X-Frame-Options with the SAMEORIGIN value, which tells the browser, that the page can only be displayed in a frame on the same origin as the page itself.
You should use the provided embed code (you can find it below every YouTube video), which is also an iframe, but with a different URL. It will only show the player.
In this case, the embed code would be:
<iframe width="560" height="315" src="//www.youtube.com/embed/C8kSrkz8Hz8" frameborder="0" allowfullscreen></iframe>
replace you Iframe with this one. this works for you.
<iframe width="640" height="390" src="//www.youtube.com/embed/C8kSrkz8Hz8" frameborder="0" allowfullscreen></iframe>
missing attributes are: frameborder="0", allowfullscreen
You should change the youtube URL to remove the "s" so it looks like this:
<iframe width="420" height="345" src="//www.youtube.com/embed/C8kSrkz8Hz8" frameborder="1" allowfullscreen></iframe>
You should also be able to embed a youtube video from the page. Please see the screenshot attached:
I tried it this way and worked for me. Changing your src="https://www.youtube.com/embed/C8kSrkz8Hz8"
following the other parameters.

How to get embedded code of autoplay youtube video

I need to embed a video in my project and I need to have a code for that so that it do not display any suggested videos at the end, and I need it it to be autoplayed when the page launches.
This is the URL of the video
Can I get help in this please?
just uncheck the box that has "suggested videos" and then copy and paste the code and it should work fine. Have a Blessed day.
Try this
<iframe width="560" height="315" src="http://www.youtube.com/embed/1WCxuHDfyUo?rel=0&autoplay=1" frameborder="0" allowfullscreen></iframe>