HTML video tag display Youtube video - html

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>

Related

Display thumbnail image over iframe embedded youtube video

I want to display an image as thumbnail and when you click on it the youtube video should play. I tried using the <video> tag but it does not support youtube videos hence couldn't set the image. I want to implement this in Reactjs. Can anyone suggest any solution to this?
<iframe
width='100%'
height='100%'
src=[youtube_video_link]
frameBorder='0'
allow='accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture'
allowFullScreen
></iframe>
I guess you can use reactplayer package in your app to show any video with thumbnail.
Here it's available: link
Basic example:
<ReactPlayer
className=[any_class_name]
light={true}
url={url}
playing
/>
the light prop attaches video thumbnail to the video.
You may also set the thumbnail as any other image(of your choice) by simply replacing true with any image URL.

Can you show youtube videos on your website without embedding them?

I have my site so that people can upload urls of the videos to the database and with php it should in theory display said video. I don't want to use the embed tag because that doesn't work from mobile device. Is there a way to use the videos with just the url's?
<video controls>
<source src="https://www.youtube.com/watch?v=S3FPvI5p8Zo" type="video/mp4">
</video>
I expect the video to show, but the actual result is it not working.
One way to do this is by using a cover photo and a link to youtube.com
<a target="_blank" href="https://www.youtube.com/watch?v=S3FPvI5p8Zo">
<img src="images/cover-image.jpg">
</a>
Another is to use jquery and fancybox (http://fancyapps.com/fancybox/3/) and create a pop up:
HTML:
<a id="fancybox-vid"></a>
JavaScript:
$('#fancybox-vid').click(function(e){
e.preventDefault();
$.fancybox({
href: "https://www.youtube.com/embed/S3FPvI5p8Zo?autoplay=1",
type: "iframe",
padding: 0,
helpers: {
overlay: {
locked: false
}
}
});
});
Besides embed tag, there are two more ways to upload a video in HTML:
1. object tag
2. iframe tag
Do you try it out?
<object width="425" height="344" data="https://www.youtube.com/embed/F9Bo89m2f6g"></object>
<iframe width="425" height="344" src="https://www.youtube.com/embed/F9Bo89m2f6g" frameborder="0" allowfullscreen></iframe>
These urls are links to a page which hosts the youtube video, not a direct link to the media content itself. It's my understanding that the video controls attribute would be for content you either host yourself or remote content that is a direct link, since you're instructing the browser to play the content on your page directly from that source. I don't think there is a way to do what you're trying to do without use of an iframe. Unless you'd like your website to try to download the media from youtube, name it, store it, and present it.
Another way to do this is by using Iframe tag and a link to youtube.com
<iframe width="560" height="315" src="https://www.youtube.com/embed/S3FPvI5p8Zo" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

iframe: Not able to run youtube videos on my html page

I am new to HTML and when I am trying to embed a youtube video in my html page using iframe tag, then it is getting embedded very well. Please see code below:
<iframe width="420" height="320" src="https://youtube.com/embed/FiMl6n64bTg"></iframe>
But when i am trying to run that video in my html page then it is showing
The video contains content from multi screen media. It is restricted from playback in certain sites. Watch on Youtube..
How can i run youtube video in my html page without this error/issue.
Thanks in advance!!!!
Try this
<iframe title="YouTube video player" class="youtube-player" type="text/html"
width="420" height="320" src="https://youtube.com/embed/FiMl6n64bTg"
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.

YouTube video in HTML5

How do I play a YouTube video in HTML5?
This is probably what you're looking for:
Force HTML5 youtube video
HTML5 video may play if the user has opted in:
<iframe class="youtube-player" type="text/html" width="640" height="385" src="http://www.youtube.com/embed/VIDEO_ID" frameborder="0"> </iframe>
HTML5-by-defualt video - notice the ?html5=1:
<iframe class="youtube-player" type="text/html" width="640" height="385" src="http://www.youtube.com/embed/VIDEO_ID?html5=1" frameborder="0"> </iframe>
The "HTML5" way of doing video would be to use a <video> tag. This post shows that it can be done, but it doesn't look like the best option. Show Youtube video source into HTML5 video tag?
You can also take a look how YouTube does it, opt in at: http://www.youtube.com/html5
If you're using safari, there's an YouTube5 extension that will make all youtube videos into html5 videos.
http://www.verticalforest.com/2010/06/09/youtube5-html5-converter-for-youtube-videos/
Supports videos that youtube does not (videos with ads etc)
You can embed videos effortlessly by right clicking the video on youtube,
copying the embed video option, and pasting it in your html where you want it to appear, The problem with this you wont have control over what is shown in the embed code apart from the clip you are interested in, ie, adverts playlists etc