Search code examples
javascriptjqueryhtmliframeautoplay

Activate Autoplay based on allow="autoplay" attribute in iframe - Google Autoplay Policy


I really tried to find an answer but couldn't. Google have changed their Autoplay Policy .

I am loading an iframe with Src to independent code, like this:

<iframe frameBorder="0" scrolling="no" allow="autoplay"
src="myurl" 
 width="640" height="480">
</iframe>

myurl is a path the a video player. I want to check if 'allow="autoplay"' was passed as iframe attribute where the player code is, and the decide if to set auto play or not.

Note, that the site where the iframe is loaded is a different site' with different code and it even sites on a different server then the myurl site.

How can I do it?


Solution

  • It can not been done. You need to use a promises to check if the auto play succeeded. I used googles way of doing it.

    Hope it will saves some time to someone :)