瀏覽代碼

tweak implementation of #1376

Hakim El Hattab 9 年之前
父節點
當前提交
3d33d27b86
共有 1 個文件被更改,包括 14 次插入2 次删除
  1. 14 2
      js/reveal.js

+ 14 - 2
js/reveal.js

@@ -2728,8 +2728,20 @@
 			// Start video playback
 			var currentVideo = currentBackground.querySelector( 'video' );
 			if( currentVideo ) {
-				if( currentVideo.currentTime > 0 ) currentVideo.currentTime = 0;
-				currentVideo.play();
+
+				var startVideo = function() {
+					currentVideo.currentTime = 0;
+					currentVideo.play();
+					currentVideo.removeEventListener( 'loadeddata', startVideo );
+				};
+
+				if( currentVideo.readyState > 1 ) {
+					startVideo();
+				}
+				else {
+					currentVideo.addEventListener( 'loadeddata', startVideo );
+				}
+
 			}
 
 			var backgroundImageURL = currentBackground.style.backgroundImage || '';