Bartosz
Bartosz

Reputation: 4592

Youtube player stopped working

I'm trying to mend Youtube player on my page which seems to be broken since this month (08/2016). I have seen Google's release notes on updates from 11/08/2016 but could not find anything relevant.

Basically, what broke is that I cannot play the video using YouTube Player API playVideo() function

When I render the page this is my html markup to hold a player:

<object type="application/x-shockwave-flash" data="//www.youtube.com/v/XYZ&amp;enablejsapi=1&amp;controls=0&amp;rel=0&amp;playerapiid=XYZ" width="100%" height="100%" id="XYZ" style="visibility: visible;"><param name="allowScriptAccess" value="always"></object>

which I'm trying to run using this function:

self.PlayYouTubeVideo = function(videoId) {
    var video = $('#' + videoId)[0];

    setTimeout(function() {
        if (typeof video.playVideo === 'function') {
            video.playVideo();

            ...further code...

        }
     }, 500);
 };

Unfortunately every time I check it, video.playVideo value is always 'undefined'. I have extended timeout but it didn't make any difference. Apparently this code was working fine last month (07/2016) and broke just recently. I never wrote it, and have very basic knowledge of Youtube player implementation.

Anyone would be willing to help?

Upvotes: 2

Views: 487

Answers (1)

paolo
paolo

Reputation: 2538

According to the documentation of the JavaScript API, the JS API is deprecated:

The deprecation of the YouTube JavaScript Player API was announced on January 27, 2015. YouTube Flash embeds have also been deprecated. See the deprecation policy for more information. Please migrate your applications to the IFrame API, which can intelligently use whichever embedded player – HTML () or Flash () – the client supports.

I'd follow their advice and migrate to the iFrame API, especially because Flash isn't a modern technology (anymore) and you would cut off people whose browsers don't support it (like most mobile users).

Upvotes: 2

Related Questions