Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embed youtube for mobile page

Is there a way to embed a link to a youtube video, so that the video will play in fullscreen on a mobile phone when the user click on the link?

The default iframe embed code will play the video inline on android phones -(

If I go to m.youtube.com they kinda does what i need, but they do it in an odd way because they generate different html and different links and protocols for viewing the video depending on which mobile phone I have.

This does make sense because the way to serve the video depend on the users phone, but is there a way for me to get some javascript/html from youtube so I can do the same thing on my own page?

like image 253
MTilsted Avatar asked Mar 25 '11 20:03

MTilsted


People also ask

How do I embed a YouTube video in mobile site?

Embed a video or playlistFrom the list of Share options, click Embed. From the box that appears, copy the HTML code. Paste the code into your website HTML. For network administrators: You will need to add youtube.com to the firewall allowlist.

How do you embed a YouTube video on mobile responsive?

Here's how to make a youtube video mobile: You will need to wrap the responsive youtube embed code with a div and specify a 50% to 60% padding bottom. Then specify the child elements (iframe, object embed) 100% width, 100% height, with absolute position.


1 Answers

The proper way to do it seems to be like so:

<iframe class="youtube-player" type="text/html" width="640" height="385" 
src="http://www.youtube.com/embed/VIDEO_ID" frameborder="0">
</iframe>

Check out the Youtube blog or that other blog post.

Now you only need to find a way to figure out which width and height to use for each device.

like image 131
webmat Avatar answered Oct 29 '22 04:10

webmat