Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Youtube videos are not streaming in <video> of HTML5

I'm trying to stream youtube videos with tag, the videos uploaded were .mp4 and supports h.246 codecs.

Code snippet as below,

<html>    
<body>    
<video control autoplay>    
<source src="http://www.youtube.com/watch?=RB_hVB6qzBc" type="video/mp4" codecs="h.264"></source>    
</video>    
</body>    
</html>    

This page is not displaying any video neither in Chrome - WINDOWS XP or in Chrome on Android 2.3.

The tag is working fine when we point the source to an video url of amazon cloud.

We are facing this problem only when same video accessed via Youtube.

Do source of mandates extension like .mp4 etc to play a media file ? Because other than this accessing a video from amazon and accessing it over Youtube are just the same.

Help of this is greatly appreciated.

Thanks.

like image 372
user1252573 Avatar asked Dec 28 '25 17:12

user1252573


1 Answers

You cannot use YouTube like that, it doesn't work that way.

First off, the link should be http://www.youtube.com/watch?v=RB_hVB6qzBc (note the ?v=). Second, that's a link to the video page, not the MP4 file itself.

If you want to embed a YouTube video, use the embed code they provide ("Share" > "Embed"):

<iframe width="420" height="315" src="http://www.youtube.com/embed/RB_hVB6qzBc" frameborder="0" allowfullscreen></iframe>

If you really wanted to use your own <video> tag to play the file, you'd have to get the actual video URL. You'd have to get the <video> tag from the YouTube page, and get the URL, and then use that. But, I'm pretty sure YouTube doesn't want you doing that.

like image 161
Rocket Hazmat Avatar answered Dec 30 '25 05:12

Rocket Hazmat