Skip to content

Commit d14727b

Browse files
committed
type check to ensure we don't call media api before media has loaded
1 parent 207b0c7 commit d14727b

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

js/reveal.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2904,7 +2904,7 @@
29042904

29052905
// HTML5 media elements
29062906
toArray( slide.querySelectorAll( 'video, audio' ) ).forEach( function( el ) {
2907-
if( el.hasAttribute( 'data-autoplay' ) ) {
2907+
if( el.hasAttribute( 'data-autoplay' ) && typeof el.play === 'function' ) {
29082908
el.play();
29092909
}
29102910
} );
@@ -2945,7 +2945,7 @@
29452945
if( slide && slide.parentNode ) {
29462946
// HTML5 media elements
29472947
toArray( slide.querySelectorAll( 'video, audio' ) ).forEach( function( el ) {
2948-
if( !el.hasAttribute( 'data-ignore' ) ) {
2948+
if( !el.hasAttribute( 'data-ignore' ) && typeof el.pause === 'function' ) {
29492949
el.pause();
29502950
}
29512951
} );

0 commit comments

Comments
 (0)