Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unrecognized feature: 'autoplay' error with YouTube embedded player

Is anyone else seeing this warning in the browser console when loading a YouTube iFrame embed player using the data 3 API?

Unrecognized feature: 'autoplay'.

The error occurs in a Google file: www-widgetapi.js:110 it appears to be a JavaScript error (this is from line 110):

c.setAttribute("allowfullscreen",1);c.setAttribute("allow","autoplay; encrypted-media");

I assume the autoplay part should simply be:

c.setAttribute("autoplay",0);

The file is here: https://s.ytimg.com/yts/jsbin/www-widgetapi-vflkvQ6Kw/www-widgetapi.js

The error is even occurring on their developer demo page: https://developers.google.com/youtube/youtube_player_demo

How do people report these things to Google?

like image 506
beachCode Avatar asked Jan 14 '18 05:01

beachCode


People also ask

How do I allow play embedded YouTube videos on one page?

If (as with this example) you utilize already embedded players then make sure you append '? enablejsapi=1' to the end of the embed URL. Essentially this manager keeps track of the registered videos. If it detects that a registered video begins to play it will pause any other registered video that is currently playing.

What is iFrame API?

Developers can use the iFrame API to programmatically create and interact with an Embed or with multiple Embeds in the same web app. The iFrame API includes methods that you can use to start playback, change the content rendering in an Embed, or stop playback.


1 Answers

I wonder if this:

https://developers.google.com/web/updates/2017/09/autoplay-policy-changes

As you may have noticed, web browsers are moving towards stricter autoplay policies in order to improve the user experience, minimize incentives to install ad blockers, and reduce data consumption on expensive and/or constrained networks. These changes are intended to give greater control of playback to users and to benefit publishers with legitimate use cases.

Chrome's autoplay policies are simple:

  • Muted autoplay is always allowed.
  • Autoplay with sound is allowed if:
    • User has interacted with the domain (click, tap, etc.).
    • On desktop, the user's Media Engagement Index threshold has been crossed, meaning the user has previously play video with sound.
    • On mobile, the user has added the site to his or her home screen.
    • Top frames can delegate autoplay permission to their iframes to allow autoplay with sound.

Has anything to do with it. I came up with the same problem and the article mentions that the way autoplay will be working from January 2018 (now! 🎉) will be changing.

I have removed an autoplay in my code, and instead used a technique described in this answer

like so:

player = new YT.Player( videoID , {
    videoId: youtubeID, // the ID of the video (mentioned above)
    playerVars: {
        // autoplay: 1, // start automatically
        controls: 0, // don't show the controls (we can't click them anyways)
        modestbranding: 1, // show smaller logo
        loop: 1, // loop when complete
        playlist: youtubeID // required for looping, matches the video ID
    },
    events : {
        'onReady' : onPlayerReady
    }
});

function onPlayerReady(event) {
    player.mute();
    player.playVideo();
}

I'm not sure if this constitutes an 'answer' so let me know if you not and I'll remove it.

like image 169
Djave Avatar answered Oct 03 '22 19:10

Djave