From ea8964ddbf7a603197fee093b206bc879ebabd33 Mon Sep 17 00:00:00 2001 From: chadmorrow Date: Fri, 30 Sep 2016 17:46:32 -0700 Subject: [PATCH] autoSlide duration with playbackRate The autoSlide duration of media elements with data-autoplay now takes the playbackRate of said media element into account when setting the duration so that autoSlide and the media element stay in sync. --- js/reveal.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/js/reveal.js b/js/reveal.js index 97f2994..09cc5b6 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -3767,12 +3767,13 @@ // If there are media elements with data-autoplay, // automatically set the autoSlide duration to the // length of that media. Not applicable if the slide - // is divided up into fragments. + // is divided up into fragments. + // playbackRate is accounted for in the duration. if( currentSlide.querySelectorAll( '.fragment' ).length === 0 ) { toArray( currentSlide.querySelectorAll( 'video, audio' ) ).forEach( function( el ) { if( el.hasAttribute( 'data-autoplay' ) ) { - if( autoSlide && el.duration * 1000 > autoSlide ) { - autoSlide = ( el.duration * 1000 ) + 1000; + if( autoSlide && (el.duration * 1000 / el.playbackRate ) > autoSlide ) { + autoSlide = ( el.duration * 1000 / el.playbackRate ) + 1000; } } } );