I’m encountering an issue with a simple modal dialog:
- When a user clicks on a button, the modal overlay appears.
- An embedded YouTube
<iframe>
is then added.
Everything works smoothly in most browsers, except for Safari 11.1.
Safari’s new auto-play policy now requires a direct click and explicit action for video playback to start:
Is there a workaround to enable autoplay for dynamically inserted YouTube (or Vimeo) iframes?
A sample YouTube iframe code snippet is provided below:
<iframe frameborder="0" allowfullscreen="" allow="autoplay; encrypted-media; fullscreen" src="https://www.youtube-nocookie.com/embed/20iMzRklHNU?rel=0&controls=0&showinfo=0&autoplay=1&enablejsapi=1"></iframe>