Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

YouTube URL in Video Tag

I am using the <video> tag, and I want to use any URL from YouTube in it.

I have this http://jsfiddle.net/wCrNw/ but it's not working.

I have checked this Show Youtube video source into HTML5 video tag? but that is not solving my problem.

    <video controls="controls"             class="video-stream"             x-webkit-airplay="allow"             data-youtube-id="N9oxmRT2YWw"   src="http://www.youtube.com/watch?v=OmxT8a9RWbE"            ></video> 
like image 604
Dinesh Kanivu Avatar asked Nov 07 '13 12:11

Dinesh Kanivu


People also ask

How do you add a URL to a video tag?

<video> HTML Tag Add the video URL to the element by using either the src attribute of the <video> element or by nesting one or more <source> elements between the opening and closing <video> tags.

Can we play YouTube video in video tag?

Video tag supports only video formats (like mp4 etc). Youtube does not expose its raw video files - it only exposes the unique id of the video. Since that id does not correspond to the actual file, video tag cannot be used.


2 Answers

MediaElement YouTube API example

Wraps the YouTube API in an HTML5 Media API wrapper, so that it can be programmed against as if it was true HTML5 <video>.

<script src="jquery.js"></script> <script src="mediaelement-and-player.min.js"></script> <link rel="stylesheet" href="mediaelementplayer.css" />  <video width="640" height="360" id="player1" preload="none">     <source type="video/youtube" src="http://www.youtube.com/watch?v=nOEw9iiopwI" /> </video>  <script>     var player = new MediaElementPlayer('#player1'); </script> 
like image 188
MrJustin Avatar answered Sep 22 '22 20:09

MrJustin


Video tag supports only video formats (like mp4 etc). Youtube does not expose its raw video files - it only exposes the unique id of the video. Since that id does not correspond to the actual file, video tag cannot be used.

If you do get hold of the actual source file using one of the youtube download sites or soft wares, you will be able to use the video tag. But even then, the url of the actual source will cease to work after a set time. So your video also will work only till then.

like image 41
Rahul Avatar answered Sep 22 '22 20:09

Rahul