diff --git a/bower.json b/bower.json index 2c142ddf..1511e44e 100644 --- a/bower.json +++ b/bower.json @@ -29,5 +29,5 @@ "type": "git", "url": "git://github.com/selz/plyr.git" }, - "license": "BSD" + "license": "MIT" } \ No newline at end of file diff --git a/changelog.md b/changelog.md index d18d2413..73748a0f 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,11 @@ # Changelog +## v1.0.20 +- Default controls included (Fixes #45) +- Volume changes on `input` as well as `change` (Fixes #43) +- Fix for undefined Play text +- License changed to MIT + ## v1.0.19 - Fixed firefox fullscreen issue (#38) diff --git a/controls.md b/controls.md index df9ce1be..b747d377 100644 --- a/controls.md +++ b/controls.md @@ -1,8 +1,8 @@ # Controls HTML -This is the markup that is rendered for the Plyr controls. The reason it's a separate option is to allow full customization of markup based on your needs. It's a pet hate of other libraries that use `` or ``s as buttons! +This is the markup that is rendered for the Plyr controls. You can use the default controls or provide a customized version of markup based on your needs. -The default Plyr setup uses a Hogan template. The reason being to allow for localization at a later date. Check out `controls.html` in `/src/templates` to get an idea of how the default html is structured. Alternatively just use the vanilla HTML below. +The demo Plyr setup uses a Hogan template. This purely to allow for localization at a later date. Check out `controls.html` in `/src/templates` to get an idea of how the default html is structured. Alternatively check out the `plyr.js` source. ## Requirements @@ -15,67 +15,65 @@ You need to add several placeholders to your html template that are replaced whe Currently all buttons and inputs need to be present for Plyr to work but later we'll make it more dynamic so if you omit a button or input, it'll still work. -## Vanilla HTML template +## Default -You can of course, just specify vanilla HTML. Here's an example snippet: +This is the default `html` option from `plyr.js`. -```html -var controls = [ -'
', - '
', - '', - '0% played', - '', - '', - '0% buffered', - '', - '
', - '', - '', - '', - '', - '', - '', - '', - 'Time', - '00:00', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', -'
' -].join("\n"); +```javascript +["
", + "
", + "", + "0% played", + "", + "", + "0% buffered", + "", + "
", + "", + "", + "", + "", + "", + "", + "", + "Time", + "00:00", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", +"
"].join("\n"); ``` \ No newline at end of file diff --git a/dist/plyr.js b/dist/plyr.js index 5b91cbde..a4905b7d 100644 --- a/dist/plyr.js +++ b/dist/plyr.js @@ -1 +1 @@ -!function(e){"use strict";function t(e,t){g.debug&&window.console&&console[t?"error":"log"](e)}function n(){var e,t,n,r=navigator.userAgent,s=navigator.appName,o=""+parseFloat(navigator.appVersion),a=parseInt(navigator.appVersion,10);return-1!==navigator.appVersion.indexOf("Windows NT")&&-1!==navigator.appVersion.indexOf("rv:11")?(s="IE",o="11;"):-1!==(t=r.indexOf("MSIE"))?(s="IE",o=r.substring(t+5)):-1!==(t=r.indexOf("Chrome"))?(s="Chrome",o=r.substring(t+7)):-1!==(t=r.indexOf("Safari"))?(s="Safari",o=r.substring(t+7),-1!==(t=r.indexOf("Version"))&&(o=r.substring(t+8))):-1!==(t=r.indexOf("Firefox"))?(s="Firefox",o=r.substring(t+8)):(e=r.lastIndexOf(" ")+1)<(t=r.lastIndexOf("/"))&&(s=r.substring(e,t),o=r.substring(t+1),s.toLowerCase()==s.toUpperCase()&&(s=navigator.appName)),-1!==(n=o.indexOf(";"))&&(o=o.substring(0,n)),-1!==(n=o.indexOf(" "))&&(o=o.substring(0,n)),a=parseInt(""+o,10),isNaN(a)&&(o=""+parseFloat(navigator.appVersion),a=parseInt(navigator.appVersion,10)),[s,a]}function r(e,t,n){return e.replace(new RegExp(t.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1"),"g"),n)}function s(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],o=s.parentNode,a=s.nextSibling;r.appendChild(s),a?o.insertBefore(r,a):o.appendChild(r)}}function o(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 a(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 m(){var e={supported:function(){try{return"localStorage"in window&&null!==window.localStorage}catch(e){return!1}}()};return e}function b(e){function a(){for(U.subcount=0;b(U.captions[U.subcount][0])U.captions.length-1){U.subcount=U.captions.length-1;break}}function p(){o(U.container,g.classes.captions.enabled,!0),g.captions.defaultActive&&(o(U.container,g.classes.captions.active,!0),U.buttons.captions.setAttribute("checked","checked"))}function d(e){var t=[];return t=e.split(" --> "),y(t[0])}function b(e){var t=[];return t=e.split(" --> "),y(t[1])}function y(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 h(e){return U.container.querySelectorAll(e)}function x(e){return h(e)[0]}function T(){try{return window.self!==window.top}catch(e){return!0}}function k(){t("Injecting custom controls.");var e=g.html;e=r(e,"{seektime}",g.seekTime),e=r(e,"{id}",U.random),U.container.insertAdjacentHTML("beforeend",e)}function w(){try{return U.controls=x(g.selectors.controls),U.buttons={},U.buttons.play=x(g.selectors.buttons.play),U.buttons.pause=x(g.selectors.buttons.pause),U.buttons.restart=x(g.selectors.buttons.restart),U.buttons.rewind=x(g.selectors.buttons.rewind),U.buttons.forward=x(g.selectors.buttons.forward),U.buttons.mute=x(g.selectors.buttons.mute),U.buttons.captions=x(g.selectors.buttons.captions),U.buttons.fullscreen=x(g.selectors.buttons.fullscreen),U.progress={},U.progress.container=x(g.selectors.progress.container),U.progress.buffer={},U.progress.buffer.bar=x(g.selectors.progress.buffer),U.progress.buffer.text=U.progress.buffer.bar.getElementsByTagName("span")[0],U.progress.played={},U.progress.played.bar=x(g.selectors.progress.played),U.progress.played.text=U.progress.played.bar.getElementsByTagName("span")[0],U.volume=x(g.selectors.buttons.volume),U.duration=x(g.selectors.duration),U.seekTime=h(g.selectors.seekTime),!0}catch(e){return t("It looks like there's a problem with your controls html. Bailing.",!0),!1}}function S(){var e=U.buttons.play.innerText;"undefined"!=typeof g.title&&g.title.length&&(e=U.buttons.play.innerText+", "+g.title),U.buttons.play.setAttribute("aria-label",e)}function F(){if(U.media=U.container.querySelectorAll("audio, video")[0],!U.media)return t("No audio or video element found!",!0),!1;if(U.media.removeAttribute("controls"),U.type="video"==U.media.tagName.toLowerCase()?"video":"audio",o(U.container,g.classes[U.type],!0),o(U.container,g.classes.stopped,null===U.media.getAttribute("autoplay")),"video"===U.type){var e=document.createElement("div");e.setAttribute("class",g.classes.videoWrapper),s(U.media,e),U.videoContainer=e}}function N(){if("video"===U.type){U.videoContainer.insertAdjacentHTML("afterbegin","
"),U.captionsContainer=x(g.selectors.captions),U.isTextTracks=!1,U.media.textTracks&&(U.isTextTracks=!0);for(var e,n="",r=U.media.childNodes,s=0;s=31||"Safari"===U.browserName&&U.browserMajorVersion>=7)&&(t("Detected IE 10/11 or Firefox 31+ or Safari 7+."),U.isTextTracks=!1),U.isTextTracks){t("TextTracks supported.");for(var u=0;ud(U.captions[U.subcount][0])&&U.media.currentTime.toFixed(1)b(U.captions[U.subcount][0])&&U.subcount=7){t("Safari 7+ detected; removing track from DOM."),a=U.media.getElementsByTagName("track");for(var m=0;mt?0:t,U.isTextTracks||"video"!==U.type||a(U)}function V(e){"number"!=typeof e&&(e=g.seekTime);var t=U.media.currentTime+e;U.media.currentTime=t>U.media.duration?U.media.duration:t,U.isTextTracks||"video"!==U.type||a(U)}function O(){o(U.container,g.classes.playing,!U.media.paused),o(U.container,g.classes.stopped,U.media.paused)}function j(e){var t=v.supportsFullScreen;e&&e.type===v.fullScreenEventName?g.fullscreen.active=v.isFullScreen():t?(v.isFullScreen()?v.cancelFullScreen():v.requestFullScreen(U.container),g.fullscreen.active=v.isFullScreen()):(g.fullscreen.active=!g.fullscreen.active,g.fullscreen.active?(i(document,"keyup",q),document.body.style.overflow="hidden"):(c(document,"keyup",q),document.body.style.overflow="")),o(U.container,g.classes.fullscreen.active,g.fullscreen.active)}function q(e){27===(e.which||e.charCode||e.keyCode)&&g.fullscreen.active&&j()}function H(e){"undefined"==typeof e&&(e=g.storage.enabled&&m().supported?window.localStorage.plyr_volume||g.volume:g.volume),e>10&&(e=10),U.volume.value=e,U.media.volume=parseFloat(e/10),W(),g.storage.enabled&&m().supported&&(window.localStorage.plyr_volume=e)}function B(e){"undefined"==typeof active&&(e=!U.media.muted,U.buttons.mute.checked=e),U.media.muted=e,W()}function R(e){"undefined"==typeof e&&(e=-1===U.container.className.indexOf(g.classes.captions.active),U.buttons.captions.checked=e),e?o(U.container,g.classes.captions.active,!0):o(U.container,g.classes.captions.active)}function W(){o(U.container,g.classes.muted,0===U.media.volume||U.media.muted)}function X(e){var t,n,r=0;switch(e.type){case"timeupdate":t=U.progress.played.bar,n=U.progress.played.text,r=u(U.media.currentTime,U.media.duration);break;case"playing":case"progress":t=U.progress.buffer.bar,n=U.progress.buffer.text,r=function(){var e=U.media.buffered;return e.length?u(e.end(0),U.media.duration):0}()}t&&r>0&&(t.value=r,n.innerHTML=r)}function _(){U.secs=parseInt(U.media.currentTime%60),U.mins=parseInt(U.media.currentTime/60%60),U.secs=("0"+U.secs).slice(-2),U.mins=("0"+U.mins).slice(-2),U.duration.innerHTML=U.mins+":"+U.secs}function D(){i(U.buttons.play,"click",function(){E(),setTimeout(function(){U.buttons.pause.focus()},100)}),i(U.buttons.pause,"click",function(){A(),setTimeout(function(){U.buttons.play.focus()},100)}),i(U.buttons.restart,"click",I),i(U.buttons.rewind,"click",L),i(U.buttons.forward,"click",V),i(U.volume,"change",function(){H(this.value)}),i(U.buttons.mute,"change",function(){B(this.checked)}),i(U.buttons.fullscreen,"click",j),i(document,v.fullScreenEventName,j),"video"===U.type&&g.click&&i(U.videoContainer,"click",function(){U.media.paused?E():U.media.ended?I():A()}),i(U.media,"timeupdate",_),i(U.media,"timeupdate",X),i(U.progress.played.bar,"click",function(e){U.pos=l(e).x/this.offsetWidth,U.media.currentTime=U.pos*U.media.duration,U.isTextTracks||"video"!==U.type||a(U)}),i(U.buttons.captions,"click",function(){R(this.checked)}),i(U.media,"ended",function(){"video"===U.type&&(U.captionsContainer.innerHTML=""),O()}),i(U.media,"progress",X),i(U.media,"playing",X),i(U.media,"volumechange",W),i(U.media,"play pause",O)}function P(){return v=f(),U.browserInfo=n(),U.browserName=U.browserInfo[0],U.browserMajorVersion=U.browserInfo[1],t(U.browserName+" "+U.browserMajorVersion),"IE"!==U.browserName||8!==U.browserMajorVersion&&9!==U.browserMajorVersion?(F(),U.random=Math.floor(1e4*Math.random()),k(),w()?(S(),N(),H(),M(),C(),D(),void 0):!1):(t("Browser not suppported.",!0),!1)}var U=this;return U.container=e,P(),{media:U.media,play:E,pause:A,restart:I,rewind:L,forward:V,setVolume:H,toggleMute:B,toggleCaptions:R}}var v,g,y={enabled:!0,debug:!1,seekTime:10,volume:5,click:!0,selectors:{container:".player",controls:".player-controls",buttons:{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",seekTime:".player-seek-time"},classes:{video:"player-video",videoWrapper:"player-video-wrapper",audio:"player-audio",stopped:"stopped",playing:"playing",muted:"muted",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}};e.setup=function(e){if(g=d(y,e),!g.enabled)return!1;for(var t=document.querySelectorAll(g.selectors.container),n=[],r=t.length-1;r>=0;r--){var s=t[r];"undefined"==typeof s.plyr&&(s.plyr=new b(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){y.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,n){return e.replace(new RegExp(t.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1"),"g"),n)}function s(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 a(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 o(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 m(){var e={supported:function(){try{return"localStorage"in window&&null!==window.localStorage}catch(e){return!1}}()};return e}function b(e){function o(){for(U.subcount=0;b(U.captions[U.subcount][0])U.captions.length-1){U.subcount=U.captions.length-1;break}}function p(){a(U.container,y.classes.captions.enabled,!0),y.captions.defaultActive&&(a(U.container,y.classes.captions.active,!0),U.buttons.captions.setAttribute("checked","checked"))}function d(e){var t=[];return t=e.split(" --> "),g(t[0])}function b(e){var t=[];return t=e.split(" --> "),g(t[1])}function g(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 h(e){return U.container.querySelectorAll(e)}function x(e){return h(e)[0]}function k(){try{return window.self!==window.top}catch(e){return!0}}function w(){t("Injecting custom controls.");var e=y.html;e=r(e,"{seektime}",y.seekTime),e=r(e,"{id}",U.random),U.container.insertAdjacentHTML("beforeend",e)}function T(){try{return U.controls=x(y.selectors.controls),U.buttons={},U.buttons.play=x(y.selectors.buttons.play),U.buttons.pause=x(y.selectors.buttons.pause),U.buttons.restart=x(y.selectors.buttons.restart),U.buttons.rewind=x(y.selectors.buttons.rewind),U.buttons.forward=x(y.selectors.buttons.forward),U.buttons.mute=x(y.selectors.buttons.mute),U.buttons.captions=x(y.selectors.buttons.captions),U.buttons.fullscreen=x(y.selectors.buttons.fullscreen),U.progress={},U.progress.container=x(y.selectors.progress.container),U.progress.buffer={},U.progress.buffer.bar=x(y.selectors.progress.buffer),U.progress.buffer.text=U.progress.buffer.bar.getElementsByTagName("span")[0],U.progress.played={},U.progress.played.bar=x(y.selectors.progress.played),U.progress.played.text=U.progress.played.bar.getElementsByTagName("span")[0],U.volume=x(y.selectors.buttons.volume),U.duration=x(y.selectors.duration),U.seekTime=h(y.selectors.seekTime),!0}catch(e){return t("It looks like there's a problem with your controls html. Bailing.",!0),!1}}function S(){var e=U.buttons.play.innerText||"Play";"undefined"!=typeof y.title&&y.title.length&&(e+=", "+y.title),U.buttons.play.setAttribute("aria-label",e)}function F(){if(U.media=U.container.querySelectorAll("audio, video")[0],!U.media)return t("No audio or video element found!",!0),!1;if(U.media.removeAttribute("controls"),U.type="video"==U.media.tagName.toLowerCase()?"video":"audio",a(U.container,y.classes[U.type],!0),a(U.container,y.classes.stopped,null===U.media.getAttribute("autoplay")),"video"===U.type){var e=document.createElement("div");e.setAttribute("class",y.classes.videoWrapper),s(U.media,e),U.videoContainer=e}}function N(){if("video"===U.type){U.videoContainer.insertAdjacentHTML("afterbegin","
"),U.captionsContainer=x(y.selectors.captions),U.isTextTracks=!1,U.media.textTracks&&(U.isTextTracks=!0);for(var e,n="",r=U.media.childNodes,s=0;s=31||"Safari"===U.browserName&&U.browserMajorVersion>=7)&&(t("Detected IE 10/11 or Firefox 31+ or Safari 7+."),U.isTextTracks=!1),U.isTextTracks){t("TextTracks supported.");for(var c=0;cd(U.captions[U.subcount][0])&&U.media.currentTime.toFixed(1)b(U.captions[U.subcount][0])&&U.subcount=7){t("Safari 7+ detected; removing track from DOM."),o=U.media.getElementsByTagName("track");for(var m=0;mt?0:t,U.isTextTracks||"video"!==U.type||o(U)}function V(e){"number"!=typeof e&&(e=y.seekTime);var t=U.media.currentTime+e;U.media.currentTime=t>U.media.duration?U.media.duration:t,U.isTextTracks||"video"!==U.type||o(U)}function O(){a(U.container,y.classes.playing,!U.media.paused),a(U.container,y.classes.stopped,U.media.paused)}function j(e){var t=v.supportsFullScreen;e&&e.type===v.fullScreenEventName?y.fullscreen.active=v.isFullScreen():t?(v.isFullScreen()?v.cancelFullScreen():v.requestFullScreen(U.container),y.fullscreen.active=v.isFullScreen()):(y.fullscreen.active=!y.fullscreen.active,y.fullscreen.active?(i(document,"keyup",q),document.body.style.overflow="hidden"):(l(document,"keyup",q),document.body.style.overflow="")),a(U.container,y.classes.fullscreen.active,y.fullscreen.active)}function q(e){27===(e.which||e.charCode||e.keyCode)&&y.fullscreen.active&&j()}function H(e){"undefined"==typeof e&&(e=y.storage.enabled&&m().supported?window.localStorage.plyr_volume||y.volume:y.volume),e>10&&(e=10),U.volume.value=e,U.media.volume=parseFloat(e/10),P(),y.storage.enabled&&m().supported&&(window.localStorage.plyr_volume=e)}function R(e){"undefined"==typeof active&&(e=!U.media.muted,U.buttons.mute.checked=e),U.media.muted=e,P()}function B(e){"undefined"==typeof e&&(e=-1===U.container.className.indexOf(y.classes.captions.active),U.buttons.captions.checked=e),e?a(U.container,y.classes.captions.active,!0):a(U.container,y.classes.captions.active)}function P(){a(U.container,y.classes.muted,0===U.media.volume||U.media.muted)}function W(e){var t,n,r=0;switch(e.type){case"timeupdate":t=U.progress.played.bar,n=U.progress.played.text,r=c(U.media.currentTime,U.media.duration);break;case"playing":case"progress":t=U.progress.buffer.bar,n=U.progress.buffer.text,r=function(){var e=U.media.buffered;return e.length?c(e.end(0),U.media.duration):0}()}t&&r>0&&(t.value=r,n.innerHTML=r)}function X(){U.secs=parseInt(U.media.currentTime%60),U.mins=parseInt(U.media.currentTime/60%60),U.secs=("0"+U.secs).slice(-2),U.mins=("0"+U.mins).slice(-2),U.duration.innerHTML=U.mins+":"+U.secs}function _(){i(U.buttons.play,"click",function(){E(),setTimeout(function(){U.buttons.pause.focus()},100)}),i(U.buttons.pause,"click",function(){A(),setTimeout(function(){U.buttons.play.focus()},100)}),i(U.buttons.restart,"click",I),i(U.buttons.rewind,"click",L),i(U.buttons.forward,"click",V),i(U.volume,"change input",function(){H(this.value)}),i(U.buttons.mute,"change",function(){R(this.checked)}),i(U.buttons.fullscreen,"click",j),i(document,v.fullScreenEventName,j),"video"===U.type&&y.click&&i(U.videoContainer,"click",function(){U.media.paused?E():U.media.ended?I():A()}),i(U.media,"timeupdate",X),i(U.media,"timeupdate",W),i(U.progress.played.bar,"click",function(e){U.pos=u(e).x/this.offsetWidth,U.media.currentTime=U.pos*U.media.duration,U.isTextTracks||"video"!==U.type||o(U)}),i(U.buttons.captions,"click",function(){B(this.checked)}),i(U.media,"ended",function(){"video"===U.type&&(U.captionsContainer.innerHTML=""),O()}),i(U.media,"progress",W),i(U.media,"playing",W),i(U.media,"volumechange",P),i(U.media,"play pause",O)}function D(){return v=f(),U.browserInfo=n(),U.browserName=U.browserInfo[0],U.browserMajorVersion=U.browserInfo[1],t(U.browserName+" "+U.browserMajorVersion),"IE"!==U.browserName||8!==U.browserMajorVersion&&9!==U.browserMajorVersion?(F(),U.random=Math.floor(1e4*Math.random()),w(),T()?(S(),N(),H(),M(),C(),_(),void 0):!1):(t("Browser not suppported.",!0),!1)}var U=this;return U.container=e,D(),{media:U.media,play:E,pause:A,restart:I,rewind:L,forward:V,setVolume:H,toggleMute:R,toggleCaptions:B}}var v,y,g={enabled:!0,debug:!1,seekTime:10,volume:5,click:!0,selectors:{container:".player",controls:".player-controls",buttons:{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",seekTime:".player-seek-time"},classes:{video:"player-video",videoWrapper:"player-video-wrapper",audio:"player-audio",stopped:"stopped",playing:"playing",muted:"muted",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},html:function(){return["
","
","","0% played","","","0% buffered","","
","","","","","","","","Time","00:00","","","","","","","","","","","","
"].join("\n")}()};e.setup=function(e){if(y=d(g,e),!y.enabled)return!1;for(var t=document.querySelectorAll(y.selectors.container),n=[],r=t.length-1;r>=0;r--){var s=t[r];"undefined"==typeof s.plyr&&(s.plyr=new b(s)),n.push(s.plyr)}return n}}(this.plyr=this.plyr||{}); \ No newline at end of file diff --git a/docs/error.html b/docs/error.html index 9d721cff..39175daa 100644 --- a/docs/error.html +++ b/docs/error.html @@ -6,7 +6,7 @@ - +
diff --git a/docs/index.html b/docs/index.html index 10cdddf3..45289a68 100644 --- a/docs/index.html +++ b/docs/index.html @@ -8,10 +8,10 @@ - + - +
@@ -67,13 +67,13 @@ - + - + \ No newline at end of file diff --git a/license.md b/license.md index 89bc0851..8531b2bb 100644 --- a/license.md +++ b/license.md @@ -1,12 +1,21 @@ -Copyright (c) 2015, Selz.com -All rights reserved. +The MIT License (MIT) -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: +Copyright (c) 2015 Selz.com -1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. -3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/package.json b/package.json index 0512601f..c6eef3da 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "plyr", - "version": "1.0.19", + "version": "1.0.20", "description": "A simple HTML5 media player using custom controls", "homepage": "http://plyr.io", "main": "gulpfile.js", @@ -39,5 +39,5 @@ "authors": [ "Sam Potts " ], - "license": "BSD" + "license": "MIT" } diff --git a/readme.md b/readme.md index 41cb0e74..353f022c 100644 --- a/readme.md +++ b/readme.md @@ -10,7 +10,7 @@ We wanted a lightweight, accessible and customisable media player that just supp ## Features - **Accessible** - full support for captions and screen readers. -- **Lightweight** - just 4.8KB minified and gzipped. +- **Lightweight** - just 5.3KB minified and gzipped. - **Customisable** - make the player look how you want with the markup you want. - **Semantic** - uses the *right* elements. `` for volume and `` for progress and well, `