1

I have been developing a video player to play YouTube videos using the YouTube JavaScript Player API. I am required to use the HTML5 mode of the player because the video must have variable speed playback ability. I have been using the html5=1 parameter to request for HTML5 mode of the player. Until recently it was working fine in latest Google Chrome and Firefox browsers.

For the past week, however, in Firefox the video started loading the Flash mode of the player. I have tried debugging, and found out that if I turn on the HTML5 player by requesting it from YouTube directly, then in Firefox the video starts playing in HTML5 mode. The parameter html5=1 has no effect in Firefox.

In Google Chrome this is not so. No matter what is set on the YouTube HTML5 settings page, the html5=1 parameter still has effect. If it is set to 1, then HTML5 mode is used. If it is set to 0, then Flash mode is used.

I have made a bare-bones test on JSFiddle.

//    after the API code downloads.
window.onYouTubeIframeAPIReady = function () {
    player = new YT.Player('player', {
        height: '390',
        width: '640',
        videoId: 'M7lc1UVf-VE',
        playerVars: {
            start: 60,
            end: 90,

            // Force the HTML5 mode.
            html5: 1,

            wmode: 'transparent',
            rel: 0,
            showinfo: 0,
            enablejsapi: 1,
            modestbranding: 1
        },
        events: {
            onReady: onPlayerReady,
            onStateChange: onPlayerStateChange
        }
    });
}

Try loading that page in Google Chrome. When you right click on the YouTube video, you will get a HTML5 menu. Now change the code from html5: 1 to html5: 0, and click Run on the top of the page. The page will reload, and if you right click on the YouTube video, you should get the Flash menu.

Please correct me if I am wrong. Can somebody point me to the reason as to why this might be happening?

Valera Rozuvan
  • 181
  • 2
  • 6
  • [Variable Speed Playback – HTML5 Video Feature](http://www.learningapi.com/2012/04/variable-speed-playback-html5-video-feature/). – Valera Rozuvan Mar 07 '14 at 09:50
  • [Force HTML5 youtube video](http://stackoverflow.com/questions/5845484/force-html5-youtube-video). – Valera Rozuvan Mar 07 '14 at 09:51
  • [YouTube JavaScript Player API Reference](https://developers.google.com/youtube/js_api_reference). – Valera Rozuvan Mar 07 '14 at 09:51
  • [Mozilla bug](https://bugzilla.mozilla.org/show_bug.cgi?id=980833). [YouTube API bug](https://code.google.com/p/gdata-issues/issues/detail?id=6085). – Valera Rozuvan Mar 07 '14 at 10:44
  • Checking FF 27.0.1 on OSX with https://www.youtube.com/html5 reveals no support for H.264, so the HTML5 player will be restricted to content they have encoded with WebM VP8 – Offbeatmammal Mar 08 '14 at 17:56
  • Looks like broken UA sniffing on the YouTube side. As [reported by Boris Zbarsky](https://bugzilla.mozilla.org/show_bug.cgi?id=980833#c2). In Firefox 22 this bug does not take place. If you use Firefox 27, and change the UA string to that of Firefox 22, this bug also does not take place. – Valera Rozuvan Mar 12 '14 at 08:30
  • Still seems to be happening in FF 28.. – Brian Lacy Mar 26 '14 at 23:48

1 Answers1

2

For some reason youtube is forcing the flash player when this is loaded via https.

If you use "tag.src = 'http://www.youtube.com/iframe_api';" it will load html5.

Also note that if you are logged into a google account in the same browser, it will force https which forces flash. At least that is what I have found in IE11 and FF28.

Update: It appears Google has fixed the issue. You can now use https and get the html5 engine.

user3473534
  • 131
  • 1
  • 10