forked from campiaperti/infra
rewrite youtube iframe embeds to force ?enablejsapi=1 (fixes #856)
This commit is contained in:
parent
06e76c1be3
commit
af61d9d10b
1 changed files with 17 additions and 0 deletions
17
js/reveal.js
17
js/reveal.js
|
@ -1959,6 +1959,8 @@
|
|||
updateSlideNumber();
|
||||
updateSlidesVisibility();
|
||||
|
||||
formatEmbeddedContent();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2542,6 +2544,21 @@
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Enforces origin-specific format rules for embedded content.
|
||||
*/
|
||||
function formatEmbeddedContent() {
|
||||
|
||||
// YouTube frames must include "?enablejsapi=1"
|
||||
toArray( dom.slides.querySelectorAll( 'iframe[src*="youtube.com/embed/"]' ) ).forEach( function( el ) {
|
||||
var src = el.getAttribute( 'src' );
|
||||
if( !/enablejsapi\=1/gi.test( src ) ) {
|
||||
el.setAttribute( 'src', src + ( !/\?/.test( src ) ? '?' : '' ) + 'enablejsapi=1' );
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Start playback of any embedded content inside of
|
||||
* the targeted slide.
|
||||
|
|
Loading…
Reference in a new issue