Safari on iOS has a policy that allows media playback only when the current javascript execution starts with a user action, usually this click event.
However, when I attach the handler to the button that launches someYoutubePlayer.playVideo(), and the user clicks on this button , this is what actually happens:
- The event is
clicktriggered in the main page window. - method
playVideoruns a postMessageon youtube<iframe /> - inside iframe a event
message - an event handler is
messagetriggered domVideo.play() , which will not work, because the current event is no longer click, butmessage , because we are in the inner iframewindow.
Does anyone know how to overcome this and launch the game from an external click event?
source
share