Browse Source

merge autoplay conflict #1771

Hakim El Hattab 7 years ago
parent
commit
313a23ba2b
1 changed files with 6 additions and 1 deletions
  1. 6 1
      js/reveal.js

+ 6 - 1
js/reveal.js

@@ -3228,10 +3228,14 @@
 				}
 
 				// Autoplay is always on for slide backgrounds
-				var autoplay = el.hasAttribute( 'data-autoplay' ) || !!closestParent( el, '.slide-background' );
+				var autoplay = 	el.hasAttribute( 'data-autoplay' ) ||
+								el.hasAttribute( 'data-paused-by-reveal' ) ||
+								!!closestParent( el, '.slide-background' );
 
 				if( autoplay && typeof el.play === 'function' ) {
 
+					el.removeAttribute( 'data-paused-by-reveal' );
+
 					if( el.readyState > 1 ) {
 						startEmbeddedMedia( { target: el } );
 					}
@@ -3344,6 +3348,7 @@
 			// HTML5 media elements
 			toArray( element.querySelectorAll( 'video, audio' ) ).forEach( function( el ) {
 				if( !el.hasAttribute( 'data-ignore' ) && typeof el.pause === 'function' ) {
+					el.setAttribute('data-paused-by-reveal', '');
 					el.pause();
 				}
 			} );