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?
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With