Skip to content

Commit 740f472

Browse files
committed
when there is data-autoplay:ing media, prolong autoSlide to match its duration hakimel#723
1 parent cb9e507 commit 740f472

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

js/reveal.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2454,6 +2454,17 @@ var Reveal = (function(){
24542454
autoSlide = config.autoSlide;
24552455
}
24562456

2457+
// If there are media elements with data-autoplay,
2458+
// automatically set the autoSlide duration to the
2459+
// length of that media
2460+
toArray( currentSlide.querySelectorAll( 'video, audio' ) ).forEach( function( el ) {
2461+
if( el.hasAttribute( 'data-autoplay' ) ) {
2462+
if( autoSlide && el.duration * 1000 > autoSlide ) {
2463+
autoSlide = ( el.duration * 1000 ) + 1000;
2464+
}
2465+
}
2466+
} );
2467+
24572468
// Cue the next auto-slide if:
24582469
// - There is an autoSlide value
24592470
// - Auto-sliding isn't paused by the user

0 commit comments

Comments
 (0)