From 0282413b69223d4487a05b9123b8da3295beebd1 Mon Sep 17 00:00:00 2001 From: Hakim El Hattab Date: Mon, 5 Mar 2018 14:59:32 +0100 Subject: [PATCH] fix autoplay of inline videos in ios --- js/reveal.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/js/reveal.js b/js/reveal.js index d4778cb..b8026c1 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -3498,9 +3498,16 @@ if( autoplay && typeof el.play === 'function' ) { + // If the media is ready, start playback if( el.readyState > 1 ) { startEmbeddedMedia( { target: el } ); } + // Mobile devices never fire a loaded event so instead + // of waiting, we initiate playback + else if( isMobileDevice ) { + el.play(); + } + // If the media isn't loaded, wait before playing else { el.removeEventListener( 'loadeddata', startEmbeddedMedia ); // remove first to avoid dupes el.addEventListener( 'loadeddata', startEmbeddedMedia );