auto play/pause html5 media when entering/leaving slide (#388)
This commit is contained in:
1 parent
18795c161f
commit
32736a791c
2 files changed
+38
-2
No files matched your search
@@ -1147,6 +1147,10 @@ var Reveal = (function(){
|
||||
}
|
||||
}
|
||||
|
||||
// Handle embedded content
|
||||
stopEmbeddedContent( previousSlide );
|
||||
startEmbeddedContent( currentSlide );
|
||||
|
||||
updateControls();
|
||||
updateProgress();
|
||||
|
||||
@@ -1419,6 +1423,38 @@ var Reveal = (function(){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Start playback of any embedded content inside of
|
||||
* the targeted slide.
|
||||
*/
|
||||
function startEmbeddedContent( slide ) {
|
||||
|
||||
if( slide ) {
|
||||
toArray( slide.querySelectorAll( 'video, audio' ) ).forEach( function( el ) {
|
||||
if( !el.hasAttribute( 'data-ignore' ) ) {
|
||||
el.play();
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop playback of any embedded content inside of
|
||||
* the targeted slide.
|
||||
*/
|
||||
function stopEmbeddedContent( slide ) {
|
||||
|
||||
if( slide ) {
|
||||
toArray( slide.querySelectorAll( 'video, audio' ) ).forEach( function( el ) {
|
||||
if( !el.hasAttribute( 'data-ignore' ) ) {
|
||||
el.pause();
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the current URL (hash) and navigates accordingly.
|
||||
*/
|
||||
|
||||
Vendored
+2
-2
@@ -1,8 +1,8 @@
|
||||
/*!
|
||||
* reveal.js 2.4.0 (2013-04-27, 18:02)
|
||||
* reveal.js 2.4.0 (2013-04-27, 18:27)
|
||||
* http://lab.hakim.se/reveal-js
|
||||
* MIT licensed
|
||||
*
|
||||
* Copyright (C) 2013 Hakim El Hattab, http://hakim.se
|
||||
*/
|
||||
var Reveal=function(){"use strict";function e(e){return xt||qt?(window.addEventListener("load",h,!1),c(yt,e),n(),r(),void 0):(document.body.setAttribute("class","no-transforms"),void 0)}function t(){if(At.theme=document.querySelector("#theme"),At.wrapper=document.querySelector(".reveal"),At.slides=document.querySelector(".reveal .slides"),!At.wrapper.querySelector(".progress")){var e=document.createElement("div");e.classList.add("progress"),e.innerHTML="<span></span>",At.wrapper.appendChild(e)}if(!At.wrapper.querySelector(".controls")){var t=document.createElement("aside");t.classList.add("controls"),t.innerHTML='<div class="navigate-left"></div><div class="navigate-right"></div><div class="navigate-up"></div><div class="navigate-down"></div>',At.wrapper.appendChild(t)}if(!At.wrapper.querySelector(".state-background")){var n=document.createElement("div");n.classList.add("state-background"),At.wrapper.appendChild(n)}if(!At.wrapper.querySelector(".pause-overlay")){var r=document.createElement("div");r.classList.add("pause-overlay"),At.wrapper.appendChild(r)}At.progress=document.querySelector(".reveal .progress"),At.progressbar=document.querySelector(".reveal .progress span"),yt.controls&&(At.controls=document.querySelector(".reveal .controls"),At.controlsLeft=l(document.querySelectorAll(".navigate-left")),At.controlsRight=l(document.querySelectorAll(".navigate-right")),At.controlsUp=l(document.querySelectorAll(".navigate-up")),At.controlsDown=l(document.querySelectorAll(".navigate-down")),At.controlsPrev=l(document.querySelectorAll(".navigate-prev")),At.controlsNext=l(document.querySelectorAll(".navigate-next")))}function n(){/iphone|ipod|android/gi.test(navigator.userAgent)&&!/crios/gi.test(navigator.userAgent)&&(window.addEventListener("load",u,!1),window.addEventListener("orientationchange",u,!1))}function r(){function e(){n.length&&head.js.apply(null,n),o()}for(var t=[],n=[],r=0,s=yt.dependencies.length;s>r;r++){var a=yt.dependencies[r];(!a.condition||a.condition())&&(a.async?n.push(a.src):t.push(a.src),"function"==typeof a.callback&&head.ready(a.src.match(/([\w\d_\-]*)\.?js$|[^\\\/]*$/i)[0],a.callback))}t.length?(head.ready(e),head.js.apply(null,t)):e()}function o(){t(),s(),Y(),setTimeout(function(){v("ready",{indexh:wt,indexv:bt,currentSlide:ft})},1)}function s(e){if(At.wrapper.classList.remove(yt.transition),"object"==typeof e&&c(yt,e),qt===!1&&(yt.transition="linear"),At.wrapper.classList.add(yt.transition),At.wrapper.setAttribute("data-transition-speed",yt.transitionSpeed),At.controls&&(At.controls.style.display=yt.controls&&At.controls?"block":"none"),At.progress&&(At.progress.style.display=yt.progress&&At.progress?"block":"none"),yt.rtl?At.wrapper.classList.add("rtl"):At.wrapper.classList.remove("rtl"),yt.center?At.wrapper.classList.add("center"):At.wrapper.classList.remove("center"),yt.mouseWheel?(document.addEventListener("DOMMouseScroll",tt,!1),document.addEventListener("mousewheel",tt,!1)):(document.removeEventListener("DOMMouseScroll",tt,!1),document.removeEventListener("mousewheel",tt,!1)),yt.rollingLinks?f():p(),yt.theme&&At.theme){var t=At.theme.getAttribute("href"),n=/[^\/]*?(?=\.css)/,r=t.match(n)[0];yt.theme!==r&&(t=t.replace(n,yt.theme),At.theme.setAttribute("href",t))}M()}function a(){Dt=!0,window.addEventListener("hashchange",lt,!1),window.addEventListener("resize",dt,!1),yt.touch&&(At.wrapper.addEventListener("touchstart",Q,!1),At.wrapper.addEventListener("touchmove",V,!1),At.wrapper.addEventListener("touchend",B,!1),window.navigator.msPointerEnabled&&(At.wrapper.addEventListener("MSPointerDown",G,!1),At.wrapper.addEventListener("MSPointerMove",J,!1),At.wrapper.addEventListener("MSPointerUp",et,!1))),yt.keyboard&&document.addEventListener("keydown",Z,!1),yt.progress&&At.progress&&At.progress.addEventListener("click",nt,!1),yt.controls&&At.controls&&["touchstart","click"].forEach(function(e){At.controlsLeft.forEach(function(t){t.addEventListener(e,rt,!1)}),At.controlsRight.forEach(function(t){t.addEventListener(e,ot,!1)}),At.controlsUp.forEach(function(t){t.addEventListener(e,st,!1)}),At.controlsDown.forEach(function(t){t.addEventListener(e,at,!1)}),At.controlsPrev.forEach(function(t){t.addEventListener(e,it,!1)}),At.controlsNext.forEach(function(t){t.addEventListener(e,ct,!1)})})}function i(){Dt=!1,document.removeEventListener("keydown",Z,!1),window.removeEventListener("hashchange",lt,!1),window.removeEventListener("resize",dt,!1),At.wrapper.removeEventListener("touchstart",Q,!1),At.wrapper.removeEventListener("touchmove",V,!1),At.wrapper.removeEventListener("touchend",B,!1),window.navigator.msPointerEnabled&&(At.wrapper.removeEventListener("MSPointerDown",G,!1),At.wrapper.removeEventListener("MSPointerMove",J,!1),At.wrapper.removeEventListener("MSPointerUp",et,!1)),yt.progress&&At.progress&&At.progress.removeEventListener("click",nt,!1),yt.controls&&At.controls&&["touchstart","click"].forEach(function(e){At.controlsLeft.forEach(function(t){t.removeEventListener(e,rt,!1)}),At.controLine truncated
|
||||
var Reveal=function(){"use strict";function e(e){return kt||Tt?(window.addEventListener("load",h,!1),c(wt,e),n(),r(),void 0):(document.body.setAttribute("class","no-transforms"),void 0)}function t(){if(xt.theme=document.querySelector("#theme"),xt.wrapper=document.querySelector(".reveal"),xt.slides=document.querySelector(".reveal .slides"),!xt.wrapper.querySelector(".progress")){var e=document.createElement("div");e.classList.add("progress"),e.innerHTML="<span></span>",xt.wrapper.appendChild(e)}if(!xt.wrapper.querySelector(".controls")){var t=document.createElement("aside");t.classList.add("controls"),t.innerHTML='<div class="navigate-left"></div><div class="navigate-right"></div><div class="navigate-up"></div><div class="navigate-down"></div>',xt.wrapper.appendChild(t)}if(!xt.wrapper.querySelector(".state-background")){var n=document.createElement("div");n.classList.add("state-background"),xt.wrapper.appendChild(n)}if(!xt.wrapper.querySelector(".pause-overlay")){var r=document.createElement("div");r.classList.add("pause-overlay"),xt.wrapper.appendChild(r)}xt.progress=document.querySelector(".reveal .progress"),xt.progressbar=document.querySelector(".reveal .progress span"),wt.controls&&(xt.controls=document.querySelector(".reveal .controls"),xt.controlsLeft=l(document.querySelectorAll(".navigate-left")),xt.controlsRight=l(document.querySelectorAll(".navigate-right")),xt.controlsUp=l(document.querySelectorAll(".navigate-up")),xt.controlsDown=l(document.querySelectorAll(".navigate-down")),xt.controlsPrev=l(document.querySelectorAll(".navigate-prev")),xt.controlsNext=l(document.querySelectorAll(".navigate-next")))}function n(){/iphone|ipod|android/gi.test(navigator.userAgent)&&!/crios/gi.test(navigator.userAgent)&&(window.addEventListener("load",u,!1),window.addEventListener("orientationchange",u,!1))}function r(){function e(){n.length&&head.js.apply(null,n),o()}for(var t=[],n=[],r=0,a=wt.dependencies.length;a>r;r++){var s=wt.dependencies[r];(!s.condition||s.condition())&&(s.async?n.push(s.src):t.push(s.src),"function"==typeof s.callback&&head.ready(s.src.match(/([\w\d_\-]*)\.?js$|[^\\\/]*$/i)[0],s.callback))}t.length?(head.ready(e),head.js.apply(null,t)):e()}function o(){t(),a(),X(),setTimeout(function(){v("ready",{indexh:Et,indexv:St,currentSlide:mt})},1)}function a(e){if(xt.wrapper.classList.remove(wt.transition),"object"==typeof e&&c(wt,e),Tt===!1&&(wt.transition="linear"),xt.wrapper.classList.add(wt.transition),xt.wrapper.setAttribute("data-transition-speed",wt.transitionSpeed),xt.controls&&(xt.controls.style.display=wt.controls&&xt.controls?"block":"none"),xt.progress&&(xt.progress.style.display=wt.progress&&xt.progress?"block":"none"),wt.rtl?xt.wrapper.classList.add("rtl"):xt.wrapper.classList.remove("rtl"),wt.center?xt.wrapper.classList.add("center"):xt.wrapper.classList.remove("center"),wt.mouseWheel?(document.addEventListener("DOMMouseScroll",rt,!1),document.addEventListener("mousewheel",rt,!1)):(document.removeEventListener("DOMMouseScroll",rt,!1),document.removeEventListener("mousewheel",rt,!1)),wt.rollingLinks?f():p(),wt.theme&&xt.theme){var t=xt.theme.getAttribute("href"),n=/[^\/]*?(?=\.css)/,r=t.match(n)[0];wt.theme!==r&&(t=t.replace(n,wt.theme),xt.theme.setAttribute("href",t))}M()}function s(){Ot=!0,window.addEventListener("hashchange",ut,!1),window.addEventListener("resize",vt,!1),wt.touch&&(xt.wrapper.addEventListener("touchstart",B,!1),xt.wrapper.addEventListener("touchmove",G,!1),xt.wrapper.addEventListener("touchend",J,!1),window.navigator.msPointerEnabled&&(xt.wrapper.addEventListener("MSPointerDown",et,!1),xt.wrapper.addEventListener("MSPointerMove",tt,!1),xt.wrapper.addEventListener("MSPointerUp",nt,!1))),wt.keyboard&&document.addEventListener("keydown",V,!1),wt.progress&&xt.progress&&xt.progress.addEventListener("click",ot,!1),wt.controls&&xt.controls&&["touchstart","click"].forEach(function(e){xt.controlsLeft.forEach(function(t){t.addEventListener(e,at,!1)}),xt.controlsRight.forEach(function(t){t.addEventListener(e,st,!1)}),xt.controlsUp.forEach(function(t){t.addEventListener(e,it,!1)}),xt.controlsDown.forEach(function(t){t.addEventListener(e,ct,!1)}),xt.controlsPrev.forEach(function(t){t.addEventListener(e,lt,!1)}),xt.controlsNext.forEach(function(t){t.addEventListener(e,dt,!1)})})}function i(){Ot=!1,document.removeEventListener("keydown",V,!1),window.removeEventListener("hashchange",ut,!1),window.removeEventListener("resize",vt,!1),xt.wrapper.removeEventListener("touchstart",B,!1),xt.wrapper.removeEventListener("touchmove",G,!1),xt.wrapper.removeEventListener("touchend",J,!1),window.navigator.msPointerEnabled&&(xt.wrapper.removeEventListener("MSPointerDown",et,!1),xt.wrapper.removeEventListener("MSPointerMove",tt,!1),xt.wrapper.removeEventListener("MSPointerUp",nt,!1)),wt.progress&&xt.progress&&xt.progress.removeEventListener("click",ot,!1),wt.controls&&xt.controls&&["touchstart","click"].forEach(function(e){xt.controlsLeft.forEach(function(t){t.removeEventListener(e,at,!1)}),xt.coLine truncated
|
||||
Reference in new issue
Block a user