MTilsted
MTilsted

Reputation: 5545

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?

Upvotes: 10

Views: 34646

Answers (5)

Raj Sahaniya
Raj Sahaniya

Reputation: 1

Try this code with embed that set

< iframe width="611" height="450" src="https://www.youtube.com/embed/EzKX4LqCgCc" allowfullscreen="allowfullscreen" mozallowfullscreen="mozallowfullscreen" msallowfullscreen="msallowfullscreen" oallowfullscreen="oallowfullscreen" webkitallowfullscreen="webkitallowfullscreen">

Upvotes: 0

You can dynamically scale the video to fit the device screen: I've been using a web application that creates the correct script for the embed code.. http://embedresponsively.com

It's a service that adjusts the embed code to allow YouTube videos to scale responsively.

Cant beleive this is not being managed by Google.

Upvotes: 2

nLL
nLL

Reputation: 5672

YouTube has an option on the embed button called 'use old embed link' that gives you an embed code.

If you want it to serve a video according to the device, you are out of luck.

Upvotes: 1

webmat
webmat

Reputation: 60566

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.

Upvotes: 11

Quentin
Quentin

Reputation: 9

I use a link from m.youtube.

You have to initiate it on a mobile as it will not work in a website.

It looks like this:

rtsp://v6.cache3.c.youtube.com/CjYLENy73wIaLQkhS9rfloZnFRMYJCAkFEIJbXYtZ29vZ2xlSARSBXdhdGNoYOTe4KOh-4e3TQw=/0/0/0/video.3gp

Quentin

Upvotes: 0

Related Questions