10

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?

MTilsted
  • 5,425
  • 9
  • 44
  • 76

5 Answers5

11

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.

webmat
  • 58,466
  • 12
  • 54
  • 59
  • I'm just now digging deeper into the iframe embedding. I hadn't noticed initially, but it appears that it's still an experimental feature as of May 20th of 2011. That's what [the API reference](http://code.google.com/apis/youtube/iframe_api_reference.html) says, and it was hinted at in the last paragraph of the blog post mentioned in my answer. – webmat May 20 '11 at 19:51
2

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.

1

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.

d-_-b
  • 21,536
  • 40
  • 150
  • 256
nLL
  • 5,662
  • 11
  • 52
  • 87
  • The problem is that the old embed code is flash based, so it will play inline on newer android devices. The odd thing is that m.youtube.com does exactly what I need, but that page don't use youtubes own embed system. – MTilsted Mar 28 '11 at 09:48
  • i belive m.youtube serves content according to your phone and youttube does not provide an api or code to use that feature on your site – nLL Mar 30 '11 at 10:58
0

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">

0

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

Quentin
  • 9
  • 1
  • 3
    But that breaks the youtube acceptable use policy, and it is not supported, so google may change code so this don't work anymore without any warnings. Which make it a rather bad solution -( – MTilsted May 07 '11 at 13:03