How to control youtube embed live stream? - html

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>

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.

Embeded youtube video error

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.

HTML video tag display Youtube video

I got some youtube urls, such as https://www.youtube.com/embed/LaXGkW_-Nvc?list=RDTDDDvaoGiDg. When I put it to html video tag, it said "Invalid source".
How to solve this problem?
When I used iframe to display videos, I had another problem as described here: Video not showing in iframe on IE, but showing on firefox and chrome.
This is my HTML:
<video width="300" height="auto" autoplay="" controls="" name="media"><source src="https://www.youtube.com/embed/LaXGkW_-Nvc?list=RDTDDDvaoGiDg"></video>
You can't use the HTML5 video tag for youtube videos, it only supports files that are either MP4, WebM and Ogg. W3C Schools
Youtube already provides you with an "embed" function on their page which auto generates the iFrame for you. Youtube Embed There are a few other methods but they are no longer used (deprecated). Youtube API
As for the issue with IE, maybe have a look at this similar question: YouTube iframe embed code not working in IE
The only way around the issue if you want to use the HTML5 video tag is to download the Youtube video in one of the specified formats.
You need to use the <iframe> tag to embed the YouTube. Please read the code below:
<iframe src="https://www.youtube.com/embed/5L3wKniOnro?autoplay=1" width="600" height="400" allow="accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

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>

The youtube video is not loading in the my local webpage

I have taken the following iframe code for the youtube video from the youtube itself.
<iframe width=”560? height=”315? src=”http://www.youtube.com/embed/V3oJR5IAMxM” frameborder=”0? allowfullscreen></iframe>
But when i try to embed this video on simple web-page inside a div element. I can see the you-tube player in the web page.But the video is not loading in my webpage. But the same video is playing for me in youtube.
Can someone tell what might be the problem,..
Is the problem with a code or with the browser, i am using mozilla 13.
HiTbmBizz,
Try this instead,
<iframe width="640" height="360" src="http://www.youtube.com/embed/V3oJR5IAMxM?feature=player_embedded" frameborder="0" allowfullscreen></iframe>
Worked for me in HTMLSandbox if you want to test.
Let me know how it goes.