Launch YouTube iframe player via (external) javascript on iOS

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?

+5
source share
1 answer

Why don't you just download the video from it, and not to iFrame? This will reduce the load on your application and there will be a leak in a minute.

e.g. http://www.youtube.com/watch?v= ....

0
source

All Articles