119

Regarding the Youtube API Blog they are experimenting with their new HTML5 Video Player.

Apparently to play a video in html5, you have to use the iframe embedding code :

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

But if the client has not joined the HTML5 Trial, the player will automatically fall back into the flash player even if the client's browser is HTML5 video capable.

How to force the HTML5 video playback if the browser supports it, even if the users are not yet involved in the HTML5 Trial?

Otherwise how to disable the flash fallback?

EDIT:

It's possible to force HTML player through links to Youtube Video, but I need this kind of feature for embedded videos.

Yashwardhan Pauranik
  • 5,370
  • 5
  • 42
  • 65
Kami
  • 5,959
  • 8
  • 38
  • 51
  • What if you were to detect HTML5 Capability with js, and implement the youtube api code accordingly. Or I should say, if HTML5 Video not supported, don't implement the youtube api as it would resort to Flash. – David Hobs Nov 16 '11 at 10:43

5 Answers5

181

I've found the solution :

You have to add the html5=1 in the src attribute of the iframe :

<iframe src="http://www.youtube.com/embed/dP15zlyra3c?html5=1"></iframe>

The video will be displayed as HTML5 if available, or fallback into flash player.

Kami
  • 5,959
  • 8
  • 38
  • 51
  • 1
    hmm - now it's not working (same vids), weird. I wonder if it only works on certain youtube servers? – UpTheCreek Mar 03 '12 at 13:02
  • 1
    Doesn't work when adding `&html5=1` to the end of a non-embedded video :/ – Zippo May 26 '12 at 18:31
  • 1
    Adding `&html5=1` (or `&html5=true` or anything like that) to the end of a hyperlink (not iframe embedded video) does not seem to work in IE without Flash. – Ryan Sep 21 '12 at 16:50
  • 1
    YouTube videos with advertisements will automatically use the Flash player – turnt Jan 06 '13 at 23:37
  • @IvanCastellanos lmao epic link. Side note- it doesn't work under Firefox 20? – blade19899 Apr 23 '13 at 20:28
  • Adding `&html5=1` to the link worked for me in Firefox (for Android) and in Chrome. You can tell which version has loaded by right clicking the video. – Justin Jun 11 '13 at 22:09
  • 8
    I think all the reports are biased. Nobody said if he/she is in "html5 beta of youtube" and this is probably key factor. When I leave the html5 beta, it seems that ?html5=1 don't do anything. Every video goes with flash. – Paweł Brewczynski Jul 13 '13 at 21:57
  • without being on the html5 trial the &html5 doesn't work in chrome 29 – Leonardo Santagada Jul 26 '13 at 14:45
  • 1
    I dont think adding html5=1 is working, though it's possible that just embedding you tube in iframe is doing the job – Sulabh Jain Jul 31 '13 at 03:29
  • http://www.youtube.com/embed/dP15zlyra3c?html5=1 is still working as of November 5 2013 – James Nov 05 '13 at 19:18
  • 1
    James's comment of youtube.com/embed/dP15zlyra3c?html5=1 does not work for me using the latest chrome on Win 8 sadly. – hak8or Jan 24 '14 at 04:19
  • 1
    Does not work Chrome 32.0.1700.107 / Ubuntu 13.10. I have HTML5 beta enabled and most of videos are played in HTML5 version but not all and that's really weird. – Umair A. Feb 12 '14 at 08:08
20

Whether or not YouTube videos play in HTML5 format depends on the setting at https://www.youtube.com/html5, per browser. Chrome prefers HTML5 playback automatically, but even the latest Firefox and Internet Explorer still use Flash if it is installed on the machine.

The parameter html5=1 does not do anything (anymore) now. (Note it is not even listed at https://developers.google.com/youtube/player_parameters.)

Vacilando
  • 2,819
  • 2
  • 30
  • 27
  • Just checked, I have chosen the HTML5 player in https://www.youtube.com/html5, but if &html5=1 is not specified as a parameter to the embed player, flash is loaded, when I specify the param HTML5 player is loaded. OS: Linux, Firefox 33 64bit. – Czar Oct 22 '14 at 14:20
  • I just tested `html5=1` in Firefox 33.0.2 and it works well (and does not require that users enable the HTML5 setting on YouTube). Without it YouTube sends the Flash version by default. – Simon East Nov 03 '14 at 10:04
  • The parameter still works, but enabling it on the html5 page makes youtube default to html5 which is better. – alanh Dec 12 '14 at 19:27
4

I tried using the iframe embed code and the HTML5 player appeared, however, for some reason the iframe was completely breaking my site.

I messed around with the old object embed code and it works perfectly fine. So if you're having problems with the iframe here's the code i used:

<object width="640" height="360">
<param name="movie" value="http://www.youtube.com/embed/VIDEO_ID?html5=1&amp;rel=0&amp;hl=en_US&amp;version=3"/>
<param name="allowFullScreen" value="true"/>
<param name="allowscriptaccess" value="always"/>
<embed width="640" height="360" src="http://www.youtube.com/embed/VIDEO_ID?html5=1&amp;rel=0&amp;hl=en_US&amp;version=3" class="youtube-player" type="text/html" allowscriptaccess="always" allowfullscreen="true"/>
</object>

hope this is useful for someone

orkenstein
  • 2,810
  • 3
  • 24
  • 45
alejandro
  • 41
  • 2
2

If you're using the iframe embed API, you can put html5: 1 as one of the playerVars arguments, like so:

player = new YT.Player('player', {
    height: '390',
    width: '640',
    videoId: '<VIDEO ID>',
    playerVars: {
        html5: 1
    },
});

Totally works.

Michael
  • 8,362
  • 6
  • 61
  • 88
samson
  • 1,152
  • 11
  • 23
0

Inline tag is used to add another src of document to the current html element.

In your case an video of a youtube and we need to specify the html type(4 or 5) to the browser externally to the link

so add ?html=5 to the end of the link.. :)