15

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?

beachCode
  • 3,202
  • 8
  • 36
  • 69
  • Upon checking [this link](https://developers.google.com/youtube/youtube_player_demo), the error is not occuring, can you verify which part or what action you have done to cause the error? – MαπμQμαπkγVπ.0 Jan 14 '18 at 23:20
  • 1
    @MαπμQμαπkγVπ.0 which browser are you using. In Chrome, I still see the error in the console on this page: https://developers.google.com/youtube/youtube_player_demo – beachCode Jan 15 '18 at 02:49
  • I get the same error from that page(youtube player demo). Also tried loading up the iframe API locally, and get the same issue. Even when autoplay is not used/referenced anywhere in my code. – Versa Jan 17 '18 at 14:13
  • I suppose that the warning message comes from the command c.setAttribute("allow","autoplay; encrypted-media"); in the widgetapi.js. The semicolon after autoplay doesn't look correct. – Piya Poonsawat Jan 28 '18 at 09:48

2 Answers2

11

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.

Djave
  • 8,595
  • 8
  • 70
  • 124
  • I appreciate the comment even if it isn't an answer. I'm not using autoplay, so it's not a question of what I do in my code. Perhaps they broke the script when they made the change you've mentioned? – beachCode Jan 15 '18 at 18:53
4

I simply removed the autoplay; from the allow attribute on my iframe element, and included autoplay=1 in the URL get paramerters for the src:

src="https://www.youtube.com/embed/Kjf0PdhFqMw?autoplay=1&enablejsapi=1&modestbranding=1&rel=0&loop=1&controls=0&showinfo=0&mute=1&wmode=transparent"

Autoplay works and that error does not happen anymore.

gotjosh
  • 831
  • 3
  • 9
  • 18
  • 1
    I'm using the data API and I'm not using Autoplay--I'm not adding the iframe myself. It really looks like a Google bug – beachCode Jan 29 '18 at 18:16