瀏覽代碼

fix autoplay of inline videos in ios

Hakim El Hattab 6 年之前
父節點
當前提交
0282413b69
共有 1 個文件被更改,包括 7 次插入0 次删除
  1. 7 0
      js/reveal.js

+ 7 - 0
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 );