type check to ensure we don't call media api before media has loaded

This commit is contained in:
Hakim El Hattab 2015-05-06 11:28:21 +02:00
parent 207b0c71ed
commit d14727b407

View file

@ -2904,7 +2904,7 @@
// HTML5 media elements // HTML5 media elements
toArray( slide.querySelectorAll( 'video, audio' ) ).forEach( function( el ) { toArray( slide.querySelectorAll( 'video, audio' ) ).forEach( function( el ) {
if( el.hasAttribute( 'data-autoplay' ) ) { if( el.hasAttribute( 'data-autoplay' ) && typeof el.play === 'function' ) {
el.play(); el.play();
} }
} ); } );
@ -2945,7 +2945,7 @@
if( slide && slide.parentNode ) { if( slide && slide.parentNode ) {
// HTML5 media elements // HTML5 media elements
toArray( slide.querySelectorAll( 'video, audio' ) ).forEach( function( el ) { toArray( slide.querySelectorAll( 'video, audio' ) ).forEach( function( el ) {
if( !el.hasAttribute( 'data-ignore' ) ) { if( !el.hasAttribute( 'data-ignore' ) && typeof el.pause === 'function' ) {
el.pause(); el.pause();
} }
} ); } );