vimeo support for autoplay/pause
This commit is contained in:
parent
af61d9d10b
commit
a7a32f941c
1 changed files with 24 additions and 1 deletions
25
js/reveal.js
25
js/reveal.js
|
@ -2545,7 +2545,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* Enforces origin-specific format rules for embedded content.
|
||||
* Enforces origin-specific format rules for embedded media.
|
||||
*/
|
||||
function formatEmbeddedContent() {
|
||||
|
||||
|
@ -2557,6 +2557,14 @@
|
|||
}
|
||||
});
|
||||
|
||||
// Vimeo frames must include "?api=1"
|
||||
toArray( dom.slides.querySelectorAll( 'iframe[src*="player.vimeo.com/"]' ) ).forEach( function( el ) {
|
||||
var src = el.getAttribute( 'src' );
|
||||
if( !/api\=1/gi.test( src ) ) {
|
||||
el.setAttribute( 'src', src + ( !/\?/.test( src ) ? '?' : '' ) + 'api=1' );
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2584,6 +2592,14 @@
|
|||
el.contentWindow.postMessage( '{"event":"command","func":"playVideo","args":""}', '*' );
|
||||
}
|
||||
});
|
||||
|
||||
// Vimeo embeds
|
||||
toArray( slide.querySelectorAll( 'iframe[src*="player.vimeo.com/"]' ) ).forEach( function( el ) {
|
||||
if( el.hasAttribute( 'data-autoplay' ) ) {
|
||||
console.log(11);
|
||||
el.contentWindow.postMessage( '{"method":"play"}', '*' );
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2613,6 +2629,13 @@
|
|||
el.contentWindow.postMessage( '{"event":"command","func":"pauseVideo","args":""}', '*' );
|
||||
}
|
||||
});
|
||||
|
||||
// Vimeo embeds
|
||||
toArray( slide.querySelectorAll( 'iframe[src*="player.vimeo.com/"]' ) ).forEach( function( el ) {
|
||||
if( !el.hasAttribute( 'data-ignore' ) && typeof el.contentWindow.postMessage === 'function' ) {
|
||||
el.contentWindow.postMessage( '{"method":"pause"}', '*' );
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue