From ae5a816df1a8d16ecb75a48c028ff89f69400865 Mon Sep 17 00:00:00 2001 From: Sam Potts Date: Mon, 9 Mar 2015 11:51:01 +1100 Subject: [PATCH 1/2] Fix for potential issue with .tagName --- dist/plyr.js | 2 +- src/js/plyr.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/plyr.js b/dist/plyr.js index adb68c82..0b586b2a 100644 --- a/dist/plyr.js +++ b/dist/plyr.js @@ -1 +1 @@ -!function(e){"use strict";function t(e,t){h.debug&&window.console&&console[t?"error":"log"](e)}function n(){var e,t,n,r=navigator.userAgent,s=navigator.appName,a=""+parseFloat(navigator.appVersion),o=parseInt(navigator.appVersion,10);return-1!==navigator.appVersion.indexOf("Windows NT")&&-1!==navigator.appVersion.indexOf("rv:11")?(s="IE",a="11;"):-1!==(t=r.indexOf("MSIE"))?(s="IE",a=r.substring(t+5)):-1!==(t=r.indexOf("Chrome"))?(s="Chrome",a=r.substring(t+7)):-1!==(t=r.indexOf("Safari"))?(s="Safari",a=r.substring(t+7),-1!==(t=r.indexOf("Version"))&&(a=r.substring(t+8))):-1!==(t=r.indexOf("Firefox"))?(s="Firefox",a=r.substring(t+8)):(e=r.lastIndexOf(" ")+1)<(t=r.lastIndexOf("/"))&&(s=r.substring(e,t),a=r.substring(t+1),s.toLowerCase()==s.toUpperCase()&&(s=navigator.appName)),-1!==(n=a.indexOf(";"))&&(a=a.substring(0,n)),-1!==(n=a.indexOf(" "))&&(a=a.substring(0,n)),o=parseInt(""+a,10),isNaN(o)&&(a=""+parseFloat(navigator.appVersion),o=parseInt(navigator.appVersion,10)),[s,o]}function r(e,t){var n=e.media;if("video"==e.type)switch(t){case"video/webm":return!(!n.canPlayType||!n.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/no/,""));case"video/mp4":return!(!n.canPlayType||!n.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"').replace(/no/,""));case"video/ogg":return!(!n.canPlayType||!n.canPlayType('video/ogg; codecs="theora"').replace(/no/,""))}else if("audio"==e.type)switch(t){case"audio/mpeg":return!(!n.canPlayType||!n.canPlayType("audio/mpeg;").replace(/no/,""));case"audio/ogg":return!(!n.canPlayType||!n.canPlayType('audio/ogg; codecs="vorbis"').replace(/no/,""));case"audio/wav":return!(!n.canPlayType||!n.canPlayType('audio/wav; codecs="1"').replace(/no/,""))}return!1}function s(e,t,n){return e.replace(new RegExp(t.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1"),"g"),n)}function a(e,t){e.length||(e=[e]);for(var n=e.length-1;n>=0;n--){var r=n>0?t.cloneNode(!0):t,s=e[n],a=s.parentNode,o=s.nextSibling;r.appendChild(s),o?a.insertBefore(r,o):a.appendChild(r)}}function o(e){e.parentNode.removeChild(e)}function i(e,t){e.insertBefore(t,e.firstChild)}function l(e,t){for(var n in t)e.setAttribute(n,t[n])}function c(e,t,n){if(e)if(e.classList)e.classList[n?"add":"remove"](t);else{var r=(" "+e.className+" ").replace(/\s+/g," ").replace(" "+t+" ","");e.className=r+(n?" "+t:"")}}function u(e,t,n,r){t=t.split(" ");for(var s=0;sn;n++){if(e.prefix=t[n],"undefined"!=typeof document[e.prefix+"CancelFullScreen"]){e.supportsFullScreen=!0;break}if("undefined"!=typeof document.msExitFullscreen&&document.msFullscreenEnabled){e.prefix="ms",e.supportsFullScreen=!0;break}}return"webkit"===e.prefix&&navigator.userAgent.match(/Version\/[\d\.]+.*Safari/)&&(e.supportsFullScreen=!1),e.supportsFullScreen&&(e.fullScreenEventName="ms"==e.prefix?"MSFullscreenChange":e.prefix+"fullscreenchange",e.isFullScreen=function(){switch(this.prefix){case"":return document.fullScreen;case"webkit":return document.webkitIsFullScreen;case"ms":return null!==document.msFullscreenElement;default:return document[this.prefix+"FullScreen"]}},e.requestFullScreen=function(e){return""===this.prefix?e.requestFullScreen():e[this.prefix+("ms"==this.prefix?"RequestFullscreen":"RequestFullScreen")]("webkit"===this.prefix?e.ALLOW_KEYBOARD_INPUT:null)},e.cancelFullScreen=function(){return""===this.prefix?document.cancelFullScreen():document[this.prefix+("ms"==this.prefix?"ExitFullscreen":"CancelFullScreen")]()},e.element=function(){return""===this.prefix?document.fullscreenElement:document[this.prefix+"FullscreenElement"]}),e}function b(){var e={supported:function(){try{return"localStorage"in window&&null!==window.localStorage}catch(e){return!1}}()};return e}function v(e){function u(e){if(!Z.usingTextTracks&&"video"===Z.type){for(Z.subcount=0,e="number"==typeof e?e:Z.media.currentTime;k(Z.captions[Z.subcount][0])Z.captions.length-1){Z.subcount=Z.captions.length-1;break}Z.media.currentTime.toFixed(1)>=v(Z.captions[Z.subcount][0])&&Z.media.currentTime.toFixed(1)<=k(Z.captions[Z.subcount][0])?(Z.currentCaption=Z.captions[Z.subcount][1],Z.captionsContainer.innerHTML=Z.currentCaption):Z.captionsContainer.innerHTML=""}}function m(){c(Z.container,h.classes.captions.enabled,!0),h.captions.defaultActive&&(c(Z.container,h.classes.captions.active,!0),Z.buttons.captions.setAttribute("checked","checked"))}function v(e){var t=[];return t=e.split(" --> "),x(t[0])}function k(e){var t=[];return t=e.split(" --> "),x(t[1])}function x(e){if(null===e||void 0===e)return 0;var t,n=[],r=[];return n=e.split(","),r=n[0].split(":"),t=Math.floor(60*r[0]*60)+Math.floor(60*r[1])+Math.floor(r[2])}function w(e){return Z.container.querySelectorAll(e)}function T(e){return w(e)[0]}function S(){try{return window.self!==window.top}catch(e){return!0}}function F(){t("Injecting custom controls.");var e=h.html;if(e=s(e,"{seektime}",h.seekTime),e=s(e,"{id}",Z.random),Z.container.insertAdjacentHTML("beforeend",e),h.tooltips)for(var n=w(h.selectors.labels),r=n.length-1;r>=0;r--){var a=n[r];c(a,h.classes.hidden,!1),c(a,h.classes.tooltip,!0)}}function N(){try{return Z.controls=T(h.selectors.controls),Z.buttons={},Z.buttons.seek=T(h.selectors.buttons.seek),Z.buttons.play=T(h.selectors.buttons.play),Z.buttons.pause=T(h.selectors.buttons.pause),Z.buttons.restart=T(h.selectors.buttons.restart),Z.buttons.rewind=T(h.selectors.buttons.rewind),Z.buttons.forward=T(h.selectors.buttons.forward),Z.buttons.mute=T(h.selectors.buttons.mute),Z.buttons.captions=T(h.selectors.buttons.captions),Z.buttons.fullscreen=T(h.selectors.buttons.fullscreen),Z.progress={},Z.progress.container=T(h.selectors.progress.container),Z.progress.buffer={},Z.progress.buffer.bar=T(h.selectors.progress.buffer),Z.progress.buffer.text=Z.progress.buffer.bar.getElementsByTagName("span")[0],Z.progress.played={},Z.progress.played.bar=T(h.selectors.progress.played),Z.progress.played.text=Z.progress.played.bar.getElementsByTagName("span")[0],Z.volume=T(h.selectors.buttons.volume),Z.duration=T(h.selectors.duration),Z.seekTime=w(h.selectors.seekTime),!0}catch(e){return t("It looks like there's a problem with your controls html. Bailing.",!0),!1}}function E(){var e=Z.buttons.play.innerText||"Play";"undefined"!=typeof h.title&&h.title.length&&(e+=", "+h.title),Z.buttons.play.setAttribute("aria-label",e)}function A(){if(Z.media=Z.container.querySelectorAll("audio, video")[0],!Z.media)return t("No audio or video element found!",!0),!1;if(Z.media.removeAttribute("controls"),Z.type="VIDEO"==Z.media.tagName?"video":"audio",c(Z.container,h.classes[Z.type],!0),c(Z.container,h.classes.stopped,null===Z.media.getAttribute("autoplay")),"video"===Z.type){var e=document.createElement("div");e.setAttribute("class",h.classes.videoWrapper),a(Z.media,e),Z.videoContainer=e}null!==Z.media.getAttribute("autoplay")&&I()}function C(){if("video"===Z.type){Z.videoContainer.insertAdjacentHTML("afterbegin","
"),Z.captionsContainer=T(h.selectors.captions),Z.usingTextTracks=!1,Z.media.textTracks&&(Z.usingTextTracks=!0);for(var e,n="",r=Z.media.childNodes,s=0;s=31||"Safari"===Z.browserName&&Z.browserMajorVersion>=7)&&(t("Detected IE 10/11 or Firefox 31+ or Safari 7+."),Z.usingTextTracks=!1),Z.usingTextTracks){t("TextTracks supported.");for(var i=0;i=7){t("Safari 7+ detected; removing track from DOM."),a=Z.media.getElementsByTagName("track");for(var d=0;dn?n=0:n>Z.media.duration&&(n=Z.media.duration),Z.media.currentTime=n.toFixed(1),t("Seeking to "+Z.media.currentTime+" seconds"),u(n)}function j(){c(Z.container,h.classes.playing,!Z.media.paused),c(Z.container,h.classes.stopped,Z.media.paused)}function q(e){var t=g.supportsFullScreen;e&&e.type===g.fullScreenEventName?h.fullscreen.active=g.isFullScreen():t?(g.isFullScreen()?g.cancelFullScreen():g.requestFullScreen(Z.container),h.fullscreen.active=g.isFullScreen()):(h.fullscreen.active=!h.fullscreen.active,h.fullscreen.active?(p(document,"keyup",H),document.body.style.overflow="hidden"):(d(document,"keyup",H),document.body.style.overflow="")),c(Z.container,h.classes.fullscreen.active,h.fullscreen.active)}function H(e){27===(e.which||e.charCode||e.keyCode)&&h.fullscreen.active&&q()}function B(e){"undefined"==typeof e&&(e=h.storage.enabled&&b().supported?window.localStorage[h.storage.key]||h.volume:h.volume),e>10&&(e=10),Z.volume.value=e,Z.media.volume=parseFloat(e/10),W(),h.storage.enabled&&b().supported&&(window.localStorage.plyr_volume=e)}function R(e){"undefined"==typeof active&&(e=!Z.media.muted,Z.buttons.mute.checked=e),Z.media.muted=e,W()}function D(e){"undefined"==typeof e&&(e=-1===Z.container.className.indexOf(h.classes.captions.active),Z.buttons.captions.checked=e),e?c(Z.container,h.classes.captions.active,!0):c(Z.container,h.classes.captions.active)}function W(){c(Z.container,h.classes.muted,0===Z.media.volume||Z.media.muted)}function _(e){var t="waiting"===e.type;clearTimeout(Z.loadingTimer),Z.loadingTimer=setTimeout(function(){c(Z.container,h.classes.loading,t)},t?250:0)}function U(e){var t=Z.progress.played.bar,n=Z.progress.played.text,r=0;if(e)switch(e.type){case"timeupdate":case"seeking":r=f(Z.media.currentTime,Z.media.duration),"timeupdate"==e.type&&(Z.buttons.seek.value=r);break;case"change":case"input":r=e.target.value;break;case"playing":case"progress":t=Z.progress.buffer.bar,n=Z.progress.buffer.text,r=function(){var e=Z.media.buffered;return e.length?f(e.end(0),Z.media.duration):0}()}t.value=r,n.innerHTML=r}function X(){Z.secs=parseInt(Z.media.currentTime%60),Z.mins=parseInt(Z.media.currentTime/60%60),Z.secs=("0"+Z.secs).slice(-2),Z.mins=("0"+Z.mins).slice(-2),Z.duration.innerHTML=Z.mins+":"+Z.secs}function J(e){X(),U(e)}function $(){for(var e=Z.media.querySelectorAll("source"),t=e.length-1;t>=0;t--)o(e[t]);Z.media.removeAttribute("src")}function z(e){if(e.src){var t=document.createElement("source");l(t,e),i(Z.media,t)}}function K(e){if(V(),L(),j(),$(),"string"==typeof e)Z.media.setAttribute("src",e);else if(e.constructor===Array)for(var t in e)z(e[t]);J(),Z.media.load(),null!==Z.media.getAttribute("autoplay")&&I()}function Y(e){"video"===Z.type&&Z.media.setAttribute("poster",e)}function G(){p(Z.buttons.play,"click",function(){I(),setTimeout(function(){Z.buttons.pause.focus()},100)}),p(Z.buttons.pause,"click",function(){V(),setTimeout(function(){Z.buttons.play.focus()},100)}),p(Z.buttons.restart,"click",L),p(Z.buttons.rewind,"click",O),p(Z.buttons.forward,"click",P),p(Z.volume,"change input",function(){B(this.value)}),p(Z.buttons.mute,"change",function(){R(this.checked)}),p(Z.buttons.fullscreen,"click",q),p(document,g.fullScreenEventName,q),"video"===Z.type&&h.click&&p(Z.videoContainer,"click",function(){Z.media.paused?I():Z.media.ended?(L(),I()):V()}),p(Z.media,"timeupdate seeking",J),p(Z.media,"timeupdate",u),p(Z.buttons.seek,"change input",L),p(Z.buttons.captions,"click",function(){D(this.checked)}),p(Z.media,"ended",function(){"video"===Z.type&&(Z.captionsContainer.innerHTML=""),j()}),p(Z.media,"progress",U),p(Z.media,"playing",U),p(Z.media,"volumechange",W),p(Z.media,"play pause",j),p(Z.media,"waiting canplay seeked",_)}function Q(){return g=y(),Z.browserInfo=n(),Z.browserName=Z.browserInfo[0],Z.browserMajorVersion=Z.browserInfo[1],t(Z.browserName+" "+Z.browserMajorVersion),"IE"!==Z.browserName||8!==Z.browserMajorVersion&&9!==Z.browserMajorVersion?(A(),Z.random=Math.floor(1e4*Math.random()),F(),N()?(E(),C(),B(),M(),G(),void 0):!1):(t("Browser not suppported.",!0),!1)}var Z=this;return Z.container=e,Q(),{media:Z.media,play:I,pause:V,restart:L,rewind:O,forward:P,seek:L,setVolume:B,toggleMute:R,toggleCaptions:D,source:K,poster:Y,support:function(e){return r(Z,e)}}}var g,h,k={enabled:!0,debug:!1,seekTime:10,volume:5,click:!0,tooltips:!1,selectors:{container:".player",controls:".player-controls",labels:"[data-player] .sr-only, label .sr-only",buttons:{seek:"[data-player='seek']",play:"[data-player='play']",pause:"[data-player='pause']",restart:"[data-player='restart']",rewind:"[data-player='rewind']",forward:"[data-player='fast-forward']",mute:"[data-player='mute']",volume:"[data-player='volume']",captions:"[data-player='captions']",fullscreen:"[data-player='fullscreen']"},progress:{container:".player-progress",buffer:".player-progress-buffer",played:".player-progress-played"},captions:".player-captions",duration:".player-duration"},classes:{video:"player-video",videoWrapper:"player-video-wrapper",audio:"player-audio",stopped:"stopped",playing:"playing",muted:"muted",loading:"loading",tooltip:"player-tooltip",hidden:"sr-only",captions:{enabled:"captions-enabled",active:"captions-active"},fullscreen:{enabled:"fullscreen-enabled",active:"fullscreen-active"}},captions:{defaultActive:!1},fullscreen:{enabled:!0,fallback:!0},storage:{enabled:!0,key:"plyr_volume"},html:function(){return["
","
","","","","0% played","","","0% buffered","","
","","","","","","","","Time","00:00","","","","","","","","","","","","
"].join("\n")}()};e.setup=function(e){if(h=m(k,e),!h.enabled)return!1;for(var t=document.querySelectorAll(h.selectors.container),n=[],r=t.length-1;r>=0;r--){var s=t[r];"VIDEO"===s.querySelectorAll("audio, video")[0].tagName&&/iPhone/i.test(navigator.userAgent)||("undefined"==typeof s.plyr&&(s.plyr=new v(s)),n.push(s.plyr))}return n}}(this.plyr=this.plyr||{}); \ No newline at end of file +!function(e){"use strict";function t(e,t){h.debug&&window.console&&console[t?"error":"log"](e)}function n(){var e,t,n,r=navigator.userAgent,s=navigator.appName,a=""+parseFloat(navigator.appVersion),o=parseInt(navigator.appVersion,10);return-1!==navigator.appVersion.indexOf("Windows NT")&&-1!==navigator.appVersion.indexOf("rv:11")?(s="IE",a="11;"):-1!==(t=r.indexOf("MSIE"))?(s="IE",a=r.substring(t+5)):-1!==(t=r.indexOf("Chrome"))?(s="Chrome",a=r.substring(t+7)):-1!==(t=r.indexOf("Safari"))?(s="Safari",a=r.substring(t+7),-1!==(t=r.indexOf("Version"))&&(a=r.substring(t+8))):-1!==(t=r.indexOf("Firefox"))?(s="Firefox",a=r.substring(t+8)):(e=r.lastIndexOf(" ")+1)<(t=r.lastIndexOf("/"))&&(s=r.substring(e,t),a=r.substring(t+1),s.toLowerCase()==s.toUpperCase()&&(s=navigator.appName)),-1!==(n=a.indexOf(";"))&&(a=a.substring(0,n)),-1!==(n=a.indexOf(" "))&&(a=a.substring(0,n)),o=parseInt(""+a,10),isNaN(o)&&(a=""+parseFloat(navigator.appVersion),o=parseInt(navigator.appVersion,10)),[s,o]}function r(e,t){var n=e.media;if("video"==e.type)switch(t){case"video/webm":return!(!n.canPlayType||!n.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/no/,""));case"video/mp4":return!(!n.canPlayType||!n.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"').replace(/no/,""));case"video/ogg":return!(!n.canPlayType||!n.canPlayType('video/ogg; codecs="theora"').replace(/no/,""))}else if("audio"==e.type)switch(t){case"audio/mpeg":return!(!n.canPlayType||!n.canPlayType("audio/mpeg;").replace(/no/,""));case"audio/ogg":return!(!n.canPlayType||!n.canPlayType('audio/ogg; codecs="vorbis"').replace(/no/,""));case"audio/wav":return!(!n.canPlayType||!n.canPlayType('audio/wav; codecs="1"').replace(/no/,""))}return!1}function s(e,t,n){return e.replace(new RegExp(t.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1"),"g"),n)}function a(e,t){e.length||(e=[e]);for(var n=e.length-1;n>=0;n--){var r=n>0?t.cloneNode(!0):t,s=e[n],a=s.parentNode,o=s.nextSibling;r.appendChild(s),o?a.insertBefore(r,o):a.appendChild(r)}}function o(e){e.parentNode.removeChild(e)}function i(e,t){e.insertBefore(t,e.firstChild)}function l(e,t){for(var n in t)e.setAttribute(n,t[n])}function c(e,t,n){if(e)if(e.classList)e.classList[n?"add":"remove"](t);else{var r=(" "+e.className+" ").replace(/\s+/g," ").replace(" "+t+" ","");e.className=r+(n?" "+t:"")}}function u(e,t,n,r){t=t.split(" ");for(var s=0;sn;n++){if(e.prefix=t[n],"undefined"!=typeof document[e.prefix+"CancelFullScreen"]){e.supportsFullScreen=!0;break}if("undefined"!=typeof document.msExitFullscreen&&document.msFullscreenEnabled){e.prefix="ms",e.supportsFullScreen=!0;break}}return"webkit"===e.prefix&&navigator.userAgent.match(/Version\/[\d\.]+.*Safari/)&&(e.supportsFullScreen=!1),e.supportsFullScreen&&(e.fullScreenEventName="ms"==e.prefix?"MSFullscreenChange":e.prefix+"fullscreenchange",e.isFullScreen=function(){switch(this.prefix){case"":return document.fullScreen;case"webkit":return document.webkitIsFullScreen;case"ms":return null!==document.msFullscreenElement;default:return document[this.prefix+"FullScreen"]}},e.requestFullScreen=function(e){return""===this.prefix?e.requestFullScreen():e[this.prefix+("ms"==this.prefix?"RequestFullscreen":"RequestFullScreen")]("webkit"===this.prefix?e.ALLOW_KEYBOARD_INPUT:null)},e.cancelFullScreen=function(){return""===this.prefix?document.cancelFullScreen():document[this.prefix+("ms"==this.prefix?"ExitFullscreen":"CancelFullScreen")]()},e.element=function(){return""===this.prefix?document.fullscreenElement:document[this.prefix+"FullscreenElement"]}),e}function b(){var e={supported:function(){try{return"localStorage"in window&&null!==window.localStorage}catch(e){return!1}}()};return e}function v(e){function u(e){if(!Z.usingTextTracks&&"video"===Z.type){for(Z.subcount=0,e="number"==typeof e?e:Z.media.currentTime;k(Z.captions[Z.subcount][0])Z.captions.length-1){Z.subcount=Z.captions.length-1;break}Z.media.currentTime.toFixed(1)>=v(Z.captions[Z.subcount][0])&&Z.media.currentTime.toFixed(1)<=k(Z.captions[Z.subcount][0])?(Z.currentCaption=Z.captions[Z.subcount][1],Z.captionsContainer.innerHTML=Z.currentCaption):Z.captionsContainer.innerHTML=""}}function m(){c(Z.container,h.classes.captions.enabled,!0),h.captions.defaultActive&&(c(Z.container,h.classes.captions.active,!0),Z.buttons.captions.setAttribute("checked","checked"))}function v(e){var t=[];return t=e.split(" --> "),w(t[0])}function k(e){var t=[];return t=e.split(" --> "),w(t[1])}function w(e){if(null===e||void 0===e)return 0;var t,n=[],r=[];return n=e.split(","),r=n[0].split(":"),t=Math.floor(60*r[0]*60)+Math.floor(60*r[1])+Math.floor(r[2])}function x(e){return Z.container.querySelectorAll(e)}function T(e){return x(e)[0]}function S(){try{return window.self!==window.top}catch(e){return!0}}function F(){t("Injecting custom controls.");var e=h.html;if(e=s(e,"{seektime}",h.seekTime),e=s(e,"{id}",Z.random),Z.container.insertAdjacentHTML("beforeend",e),h.tooltips)for(var n=x(h.selectors.labels),r=n.length-1;r>=0;r--){var a=n[r];c(a,h.classes.hidden,!1),c(a,h.classes.tooltip,!0)}}function N(){try{return Z.controls=T(h.selectors.controls),Z.buttons={},Z.buttons.seek=T(h.selectors.buttons.seek),Z.buttons.play=T(h.selectors.buttons.play),Z.buttons.pause=T(h.selectors.buttons.pause),Z.buttons.restart=T(h.selectors.buttons.restart),Z.buttons.rewind=T(h.selectors.buttons.rewind),Z.buttons.forward=T(h.selectors.buttons.forward),Z.buttons.mute=T(h.selectors.buttons.mute),Z.buttons.captions=T(h.selectors.buttons.captions),Z.buttons.fullscreen=T(h.selectors.buttons.fullscreen),Z.progress={},Z.progress.container=T(h.selectors.progress.container),Z.progress.buffer={},Z.progress.buffer.bar=T(h.selectors.progress.buffer),Z.progress.buffer.text=Z.progress.buffer.bar.getElementsByTagName("span")[0],Z.progress.played={},Z.progress.played.bar=T(h.selectors.progress.played),Z.progress.played.text=Z.progress.played.bar.getElementsByTagName("span")[0],Z.volume=T(h.selectors.buttons.volume),Z.duration=T(h.selectors.duration),Z.seekTime=x(h.selectors.seekTime),!0}catch(e){return t("It looks like there's a problem with your controls html. Bailing.",!0),!1}}function C(){var e=Z.buttons.play.innerText||"Play";"undefined"!=typeof h.title&&h.title.length&&(e+=", "+h.title),Z.buttons.play.setAttribute("aria-label",e)}function A(){if(Z.media=Z.container.querySelectorAll("audio, video")[0],!Z.media)return t("No audio or video element found!",!0),!1;if(Z.media.removeAttribute("controls"),Z.type=Z.media.tagName.toLowerCase(),c(Z.container,h.classes[Z.type],!0),c(Z.container,h.classes.stopped,null===Z.media.getAttribute("autoplay")),"video"===Z.type){var e=document.createElement("div");e.setAttribute("class",h.classes.videoWrapper),a(Z.media,e),Z.videoContainer=e}null!==Z.media.getAttribute("autoplay")&&I()}function E(){if("video"===Z.type){Z.videoContainer.insertAdjacentHTML("afterbegin","
"),Z.captionsContainer=T(h.selectors.captions),Z.usingTextTracks=!1,Z.media.textTracks&&(Z.usingTextTracks=!0);for(var e,n="",r=Z.media.childNodes,s=0;s=31||"Safari"===Z.browserName&&Z.browserMajorVersion>=7)&&(t("Detected IE 10/11 or Firefox 31+ or Safari 7+."),Z.usingTextTracks=!1),Z.usingTextTracks){t("TextTracks supported.");for(var i=0;i=7){t("Safari 7+ detected; removing track from DOM."),a=Z.media.getElementsByTagName("track");for(var d=0;dn?n=0:n>Z.media.duration&&(n=Z.media.duration),Z.media.currentTime=n.toFixed(1),t("Seeking to "+Z.media.currentTime+" seconds"),u(n)}function j(){c(Z.container,h.classes.playing,!Z.media.paused),c(Z.container,h.classes.stopped,Z.media.paused)}function q(e){var t=g.supportsFullScreen;e&&e.type===g.fullScreenEventName?h.fullscreen.active=g.isFullScreen():t?(g.isFullScreen()?g.cancelFullScreen():g.requestFullScreen(Z.container),h.fullscreen.active=g.isFullScreen()):(h.fullscreen.active=!h.fullscreen.active,h.fullscreen.active?(p(document,"keyup",H),document.body.style.overflow="hidden"):(d(document,"keyup",H),document.body.style.overflow="")),c(Z.container,h.classes.fullscreen.active,h.fullscreen.active)}function H(e){27===(e.which||e.charCode||e.keyCode)&&h.fullscreen.active&&q()}function B(e){"undefined"==typeof e&&(e=h.storage.enabled&&b().supported?window.localStorage[h.storage.key]||h.volume:h.volume),e>10&&(e=10),Z.volume.value=e,Z.media.volume=parseFloat(e/10),_(),h.storage.enabled&&b().supported&&(window.localStorage.plyr_volume=e)}function R(e){"undefined"==typeof active&&(e=!Z.media.muted,Z.buttons.mute.checked=e),Z.media.muted=e,_()}function W(e){"undefined"==typeof e&&(e=-1===Z.container.className.indexOf(h.classes.captions.active),Z.buttons.captions.checked=e),e?c(Z.container,h.classes.captions.active,!0):c(Z.container,h.classes.captions.active)}function _(){c(Z.container,h.classes.muted,0===Z.media.volume||Z.media.muted)}function D(e){var t="waiting"===e.type;clearTimeout(Z.loadingTimer),Z.loadingTimer=setTimeout(function(){c(Z.container,h.classes.loading,t)},t?250:0)}function U(e){var t=Z.progress.played.bar,n=Z.progress.played.text,r=0;if(e)switch(e.type){case"timeupdate":case"seeking":r=f(Z.media.currentTime,Z.media.duration),"timeupdate"==e.type&&(Z.buttons.seek.value=r);break;case"change":case"input":r=e.target.value;break;case"playing":case"progress":t=Z.progress.buffer.bar,n=Z.progress.buffer.text,r=function(){var e=Z.media.buffered;return e.length?f(e.end(0),Z.media.duration):0}()}t.value=r,n.innerHTML=r}function X(){Z.secs=parseInt(Z.media.currentTime%60),Z.mins=parseInt(Z.media.currentTime/60%60),Z.secs=("0"+Z.secs).slice(-2),Z.mins=("0"+Z.mins).slice(-2),Z.duration.innerHTML=Z.mins+":"+Z.secs}function J(e){X(),U(e)}function $(){for(var e=Z.media.querySelectorAll("source"),t=e.length-1;t>=0;t--)o(e[t]);Z.media.removeAttribute("src")}function z(e){if(e.src){var t=document.createElement("source");l(t,e),i(Z.media,t)}}function K(e){if(L(),O(),j(),$(),"string"==typeof e)Z.media.setAttribute("src",e);else if(e.constructor===Array)for(var t in e)z(e[t]);J(),Z.media.load(),null!==Z.media.getAttribute("autoplay")&&I()}function Y(e){"video"===Z.type&&Z.media.setAttribute("poster",e)}function G(){p(Z.buttons.play,"click",function(){I(),setTimeout(function(){Z.buttons.pause.focus()},100)}),p(Z.buttons.pause,"click",function(){L(),setTimeout(function(){Z.buttons.play.focus()},100)}),p(Z.buttons.restart,"click",O),p(Z.buttons.rewind,"click",V),p(Z.buttons.forward,"click",P),p(Z.volume,"change input",function(){B(this.value)}),p(Z.buttons.mute,"change",function(){R(this.checked)}),p(Z.buttons.fullscreen,"click",q),p(document,g.fullScreenEventName,q),"video"===Z.type&&h.click&&p(Z.videoContainer,"click",function(){Z.media.paused?I():Z.media.ended?(O(),I()):L()}),p(Z.media,"timeupdate seeking",J),p(Z.media,"timeupdate",u),p(Z.buttons.seek,"change input",O),p(Z.buttons.captions,"click",function(){W(this.checked)}),p(Z.media,"ended",function(){"video"===Z.type&&(Z.captionsContainer.innerHTML=""),j()}),p(Z.media,"progress",U),p(Z.media,"playing",U),p(Z.media,"volumechange",_),p(Z.media,"play pause",j),p(Z.media,"waiting canplay seeked",D)}function Q(){return g=y(),Z.browserInfo=n(),Z.browserName=Z.browserInfo[0],Z.browserMajorVersion=Z.browserInfo[1],t(Z.browserName+" "+Z.browserMajorVersion),"IE"!==Z.browserName||8!==Z.browserMajorVersion&&9!==Z.browserMajorVersion?(A(),Z.random=Math.floor(1e4*Math.random()),F(),N()?(C(),E(),B(),M(),G(),void 0):!1):(t("Browser not suppported.",!0),!1)}var Z=this;return Z.container=e,Q(),{media:Z.media,play:I,pause:L,restart:O,rewind:V,forward:P,seek:O,setVolume:B,toggleMute:R,toggleCaptions:W,source:K,poster:Y,support:function(e){return r(Z,e)}}}var g,h,k={enabled:!0,debug:!1,seekTime:10,volume:5,click:!0,tooltips:!1,selectors:{container:".player",controls:".player-controls",labels:"[data-player] .sr-only, label .sr-only",buttons:{seek:"[data-player='seek']",play:"[data-player='play']",pause:"[data-player='pause']",restart:"[data-player='restart']",rewind:"[data-player='rewind']",forward:"[data-player='fast-forward']",mute:"[data-player='mute']",volume:"[data-player='volume']",captions:"[data-player='captions']",fullscreen:"[data-player='fullscreen']"},progress:{container:".player-progress",buffer:".player-progress-buffer",played:".player-progress-played"},captions:".player-captions",duration:".player-duration"},classes:{video:"player-video",videoWrapper:"player-video-wrapper",audio:"player-audio",stopped:"stopped",playing:"playing",muted:"muted",loading:"loading",tooltip:"player-tooltip",hidden:"sr-only",captions:{enabled:"captions-enabled",active:"captions-active"},fullscreen:{enabled:"fullscreen-enabled",active:"fullscreen-active"}},captions:{defaultActive:!1},fullscreen:{enabled:!0,fallback:!0},storage:{enabled:!0,key:"plyr_volume"},html:function(){return["
","
","","","","0% played","","","0% buffered","","
","","","","","","","","Time","00:00","","","","","","","","","","","","
"].join("\n")}()};e.setup=function(e){if(h=m(k,e),!h.enabled)return!1;for(var t=document.querySelectorAll(h.selectors.container),n=[],r=t.length-1;r>=0;r--){var s=t[r];"video"===s.querySelectorAll("audio, video")[0].tagName.toLowerCase()&&/iPhone/i.test(navigator.userAgent)||("undefined"==typeof s.plyr&&(s.plyr=new v(s)),n.push(s.plyr))}return n}}(this.plyr=this.plyr||{}); \ No newline at end of file diff --git a/src/js/plyr.js b/src/js/plyr.js index 90ef2d8e..0b9dbf77 100644 --- a/src/js/plyr.js +++ b/src/js/plyr.js @@ -644,7 +644,7 @@ player.media.removeAttribute("controls"); // Set media type - player.type = (player.media.tagName == "VIDEO" ? "video" : "audio"); + player.type = player.media.tagName.toLowerCase(); // Add type class _toggleClass(player.container, config.classes[player.type], true); @@ -1357,7 +1357,7 @@ // Disabled for