From 6831f6c17415c6c20269f3d61e673482442319b6 Mon Sep 17 00:00:00 2001 From: Markku Roponen Date: Mon, 12 Dec 2016 16:30:07 +0200 Subject: [PATCH 1/4] #1770, resume playback for paused media. --- js/reveal.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/js/reveal.js b/js/reveal.js index 2c92954..9594255 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -3016,7 +3016,8 @@ // HTML5 media elements toArray( slide.querySelectorAll( 'video, audio' ) ).forEach( function( el ) { - if( el.hasAttribute( 'data-autoplay' ) && typeof el.play === 'function' ) { + if( ( el.hasAttribute( 'data-autoplay' ) || el.hasAttribute( 'data-paused-by-reveal' ) ) && typeof el.play === 'function' ) { + el.removeAttribute('data-paused-by-reveal'); el.play(); } } ); @@ -3071,6 +3072,7 @@ // HTML5 media elements toArray( slide.querySelectorAll( 'video, audio' ) ).forEach( function( el ) { if( !el.hasAttribute( 'data-ignore' ) && typeof el.pause === 'function' ) { + el.addAttribute('data-paused-by-reveal'); el.pause(); } } ); From 54bfad62d7292c0a7e2e7d74b11493c0a37636c9 Mon Sep 17 00:00:00 2001 From: Markku Roponen Date: Mon, 12 Dec 2016 16:41:52 +0200 Subject: [PATCH 2/4] #1770, fixed function name. --- js/reveal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/reveal.js b/js/reveal.js index 9594255..fd0e324 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -3072,7 +3072,7 @@ // HTML5 media elements toArray( slide.querySelectorAll( 'video, audio' ) ).forEach( function( el ) { if( !el.hasAttribute( 'data-ignore' ) && typeof el.pause === 'function' ) { - el.addAttribute('data-paused-by-reveal'); + el.setAttribute('data-paused-by-reveal'); el.pause(); } } ); From da40eafccd1e62f5754069edc2ddc4706055b2ff Mon Sep 17 00:00:00 2001 From: Markku Roponen Date: Mon, 12 Dec 2016 16:44:24 +0200 Subject: [PATCH 3/4] #1770, added second argument for setAttribute --- js/reveal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/reveal.js b/js/reveal.js index fd0e324..c8ce5a2 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -3072,7 +3072,7 @@ // HTML5 media elements toArray( slide.querySelectorAll( 'video, audio' ) ).forEach( function( el ) { if( !el.hasAttribute( 'data-ignore' ) && typeof el.pause === 'function' ) { - el.setAttribute('data-paused-by-reveal'); + el.setAttribute('data-paused-by-reveal', ''); el.pause(); } } ); From 962c6c133b0860b5ad4d99d9fb36eca625de5b7a Mon Sep 17 00:00:00 2001 From: Markku Roponen Date: Tue, 13 Dec 2016 16:02:26 +0200 Subject: [PATCH 4/4] #1770, set 'data-paused-by-reveal' attribute only for the media elements, which are not already in paused state. --- js/reveal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/reveal.js b/js/reveal.js index c8ce5a2..6781639 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -3071,7 +3071,7 @@ if( slide && slide.parentNode ) { // HTML5 media elements toArray( slide.querySelectorAll( 'video, audio' ) ).forEach( function( el ) { - if( !el.hasAttribute( 'data-ignore' ) && typeof el.pause === 'function' ) { + if( !el.hasAttribute( 'data-ignore' ) && typeof el.pause === 'function' && el.paused === false ) { el.setAttribute('data-paused-by-reveal', ''); el.pause(); }