video background playback

This commit is contained in:
Hakim El Hattab 2014-04-04 09:22:15 +02:00
parent 43bf882d08
commit 170aa31d6f
2 changed files with 20 additions and 6 deletions

View File

@ -2001,7 +2001,7 @@ var Reveal = (function(){
} }
if( includeAll || h === indexh ) { if( includeAll || h === indexh ) {
toArray( backgroundh.childNodes ).forEach( function( backgroundv, v ) { toArray( backgroundh.querySelectorAll( 'section' ) ).forEach( function( backgroundv, v ) {
if( v < indexv ) { if( v < indexv ) {
backgroundv.className = 'slide-background past'; backgroundv.className = 'slide-background past';
@ -2021,9 +2021,22 @@ var Reveal = (function(){
} ); } );
// Stop any currently playing video background
if( previousBackground ) {
var previousVideo = previousBackground.querySelector( 'video' );
if( previousVideo ) previousVideo.pause();
}
if( currentBackground ) {
// Start video playback
var currentVideo = currentBackground.querySelector( 'video' );
if( currentVideo ) currentVideo.play();
// Don't transition between identical backgrounds. This // Don't transition between identical backgrounds. This
// prevents unwanted flicker. // prevents unwanted flicker.
if( currentBackground ) {
var previousBackgroundHash = previousBackground ? previousBackground.getAttribute( 'data-background-hash' ) : null; var previousBackgroundHash = previousBackground ? previousBackground.getAttribute( 'data-background-hash' ) : null;
var currentBackgroundHash = currentBackground.getAttribute( 'data-background-hash' ); var currentBackgroundHash = currentBackground.getAttribute( 'data-background-hash' );
if( currentBackgroundHash && currentBackgroundHash === previousBackgroundHash && currentBackground !== previousBackground ) { if( currentBackgroundHash && currentBackgroundHash === previousBackgroundHash && currentBackground !== previousBackground ) {
@ -2031,6 +2044,7 @@ var Reveal = (function(){
} }
previousBackground = currentBackground; previousBackground = currentBackground;
} }
// Allow the first background to apply without transition // Allow the first background to apply without transition

6
js/reveal.min.js vendored

File diff suppressed because one or more lines are too long