Compare commits
47 Commits
Author | SHA1 | Date | |
---|---|---|---|
bcf88cd024 | |||
4957e4d80c | |||
605f8a8249 | |||
7490a7e7f3 | |||
f32527feb4 | |||
a971850d26 | |||
382397407f | |||
82809235b9 | |||
7d5c507f16 | |||
bc139f16a7 | |||
f6f3284dc5 | |||
f4d2f1856f | |||
871e19ed92 | |||
72998c4c41 | |||
da48be495b | |||
c843ed3460 | |||
4232aa9ea4 | |||
f6612fa78c | |||
96ae866baa | |||
a1d5bccac2 | |||
a9bb8afca4 | |||
28cd92b708 | |||
a44c7ecc3a | |||
5214c5d55d | |||
3e6ed7b69b | |||
7d2a8d343a | |||
03aacf483f | |||
73a1391f2f | |||
660ff0434d | |||
94208dce76 | |||
efe54fbba4 | |||
10561d6c83 | |||
0ef87f93a6 | |||
a3ed309342 | |||
08b4c09b89 | |||
a509a5e1bc | |||
bec10e7836 | |||
f9a184800b | |||
f428c3ff8b | |||
97eb40a8e3 | |||
8211631950 | |||
a17cbb0e8b | |||
8098be6f93 | |||
1c73c9fbfe | |||
978606edb4 | |||
435b5c74bf | |||
15fd7041ab |
28
.github/issue_template.md
vendored
Normal file
28
.github/issue_template.md
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<!---
|
||||||
|
Please use this issue template as it makes replicating and fixing the issue easier!
|
||||||
|
--->
|
||||||
|
|
||||||
|
- [ ] Issue does not already exist
|
||||||
|
- [ ] Issue observed on https://plyr.io
|
||||||
|
|
||||||
|
### Expected behaviour
|
||||||
|
|
||||||
|
### Actual behaviour
|
||||||
|
|
||||||
|
### Environment
|
||||||
|
|
||||||
|
- Browser:
|
||||||
|
- Version:
|
||||||
|
- Operating System:
|
||||||
|
- Version:
|
||||||
|
|
||||||
|
Players affected:
|
||||||
|
- [ ] HTML5 Video
|
||||||
|
- [ ] HTML5 Audio
|
||||||
|
- [ ] YouTube
|
||||||
|
- [ ] Vimeo
|
||||||
|
|
||||||
|
### Steps to reproduce
|
||||||
|
-
|
||||||
|
|
||||||
|
### Relevant links
|
8
.github/pull_request_template.md
vendored
Normal file
8
.github/pull_request_template.md
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
### Link to related issue (if applicable)
|
||||||
|
|
||||||
|
### Sumary of proposed changes
|
||||||
|
|
||||||
|
### Task list
|
||||||
|
|
||||||
|
- [ ] Tested on [supported browsers](https://github.com/sampotts/plyr#browser-support)
|
||||||
|
- [ ] Gulp build completed
|
11
.jsbeautifyrc
Normal file
11
.jsbeautifyrc
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"html": {
|
||||||
|
"allowed_file_extensions": []
|
||||||
|
},
|
||||||
|
"css": {
|
||||||
|
"allowed_file_extensions": []
|
||||||
|
},
|
||||||
|
"js": {
|
||||||
|
"allowed_file_extensions": []
|
||||||
|
}
|
||||||
|
}
|
31
changelog.md
31
changelog.md
@ -1,5 +1,36 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## v2.0.12
|
||||||
|
- Ability to set custom `blankUrl` for source changes (https://github.com/sampotts/plyr/pull/504)
|
||||||
|
- Ability to set caption button listener (https://github.com/sampotts/plyr/pull/468)
|
||||||
|
|
||||||
|
## v2.0.11
|
||||||
|
- Fix for `cleanUp` being called twice (thanks to @sebastiancarlsson)
|
||||||
|
- Fix for YouTube controls on iPad (fixes #391)
|
||||||
|
|
||||||
|
## v2.0.10
|
||||||
|
- Added seek event fixes for Vimeo and YouTube (fixes #409)
|
||||||
|
- Added support for embed URLs rather than ID only (fixes #345)
|
||||||
|
|
||||||
|
## v2.0.9
|
||||||
|
- Temporary patch for the YouTube API issues with `getDuration()` (relates to #374)
|
||||||
|
|
||||||
|
## v2.0.8
|
||||||
|
- Added `isPaused()` API method (thanks to @darrena092)
|
||||||
|
- Allowed `.on()` API method to be chainable (thanks to @gurupras) (fixes #357)
|
||||||
|
- Improved the "awful" rendering of captions on small screens in fullscreen mode (fixes #390)
|
||||||
|
- Fix for Firefox VTT compatibility (thanks to @magourex)
|
||||||
|
- Fix for Firefox Developer Edition blank video due to `-webkit-mask-image` issue (fixes #392)
|
||||||
|
- Added Issue and PR templates with the aim of reducing duplicate or duff issues
|
||||||
|
|
||||||
|
## v2.0.7
|
||||||
|
- Fixed `getCurrentTime()` method (fixes #351)
|
||||||
|
- Added `getVolume()` , `isMuted()` and `getDuration()` API methods (fixes #346)
|
||||||
|
|
||||||
|
## v2.0.6
|
||||||
|
- Fixed merge issue with `Updated define to work with AMD imports #326` PR
|
||||||
|
- Code formatting
|
||||||
|
|
||||||
## v2.0.5
|
## v2.0.5
|
||||||
- Fix for Vimeo in IE9 & IE10
|
- Fix for Vimeo in IE9 & IE10
|
||||||
- Fix for HTML5 elements not firing `ready` event
|
- Fix for HTML5 elements not firing `ready` event
|
||||||
|
2
demo/dist/demo.css
vendored
2
demo/dist/demo.css
vendored
File diff suppressed because one or more lines are too long
2
demo/dist/demo.js
vendored
2
demo/dist/demo.js
vendored
@ -1 +1 @@
|
|||||||
"document"in self&&("classList"in document.createElement("_")?!function(){"use strict";var e=document.createElement("_");if(e.classList.add("c1","c2"),!e.classList.contains("c2")){var t=function(e){var t=DOMTokenList.prototype[e];DOMTokenList.prototype[e]=function(e){var i,s=arguments.length;for(i=0;s>i;i++)e=arguments[i],t.call(this,e)}};t("add"),t("remove")}if(e.classList.toggle("c3",!1),e.classList.contains("c3")){var i=DOMTokenList.prototype.toggle;DOMTokenList.prototype.toggle=function(e,t){return 1 in arguments&&!this.contains(e)==!t?t:i.call(this,e)}}e=null}():!function(e){"use strict";if("Element"in e){var t="classList",i="prototype",s=e.Element[i],o=Object,n=String[i].trim||function(){return this.replace(/^\s+|\s+$/g,"")},r=Array[i].indexOf||function(e){for(var t=0,i=this.length;i>t;t++)if(t in this&&this[t]===e)return t;return-1},a=function(e,t){this.name=e,this.code=DOMException[e],this.message=t},c=function(e,t){if(""===t)throw new a("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(t))throw new a("INVALID_CHARACTER_ERR","String contains an invalid character");return r.call(e,t)},l=function(e){for(var t=n.call(e.getAttribute("class")||""),i=t?t.split(/\s+/):[],s=0,o=i.length;o>s;s++)this.push(i[s]);this._updateClassName=function(){e.setAttribute("class",this.toString())}},u=l[i]=[],d=function(){return new l(this)};if(a[i]=Error[i],u.item=function(e){return this[e]||null},u.contains=function(e){return e+="",-1!==c(this,e)},u.add=function(){var e,t=arguments,i=0,s=t.length,o=!1;do e=t[i]+"",-1===c(this,e)&&(this.push(e),o=!0);while(++i<s);o&&this._updateClassName()},u.remove=function(){var e,t,i=arguments,s=0,o=i.length,n=!1;do for(e=i[s]+"",t=c(this,e);-1!==t;)this.splice(t,1),n=!0,t=c(this,e);while(++s<o);n&&this._updateClassName()},u.toggle=function(e,t){e+="";var i=this.contains(e),s=i?t!==!0&&"remove":t!==!1&&"add";return s&&this[s](e),t===!0||t===!1?t:!i},u.toString=function(){return this.join(" ")},o.defineProperty){var p={get:d,enumerable:!0,configurable:!0};try{o.defineProperty(s,t,p)}catch(h){-2146823252===h.number&&(p.enumerable=!1,o.defineProperty(s,t,p))}}else o[i].__defineGetter__&&s.__defineGetter__(t,d)}}(self)),function(){function e(e,t,i){if(e)if(e.classList)e.classList[i?"add":"remove"](t);else{var s=(" "+e.className+" ").replace(/\s+/g," ").replace(" "+t+" ","");e.className=s+(i?" "+t:"")}}function t(t,i){if(t in n&&(i||t!=r)&&(r.length||t!=n.video)){switch(t){case n.video:s.source({type:"video",title:"View From A Blue Moon",sources:[{src:"https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.mp4",type:"video/mp4"},{src:"https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.webm",type:"video/webm"}],poster:"https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.jpg",tracks:[{kind:"captions",label:"English",srclang:"en",src:"https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.en.vtt","default":!0}]});break;case n.audio:s.source({type:"audio",title:"Kishi Bashi – “It All Began With A Burst”",sources:[{src:"https://cdn.selz.com/plyr/1.5/Kishi_Bashi_-_It_All_Began_With_a_Burst.mp3",type:"audio/mp3"},{src:"https://cdn.selz.com/plyr/1.5/Kishi_Bashi_-_It_All_Began_With_a_Burst.ogg",type:"audio/ogg"}]});break;case n.youtube:s.source({type:"video",title:"View From A Blue Moon",sources:[{src:"bTqVqk7FSmY",type:"youtube"}]});break;case n.vimeo:s.source({type:"video",title:"View From A Blue Moon",sources:[{src:"143418951",type:"vimeo"}]})}r=t;for(var a=o.length-1;a>=0;a--)e(o[a].parentElement,"active",!1);e(document.querySelector('[data-source="'+t+'"]').parentElement,"active",!0)}}var i=plyr.setup({debug:!0,title:"Video demo",iconUrl:"../dist/plyr.svg",tooltips:{controls:!0},captions:{defaultActive:!0}});plyr.loadSprite("dist/demo.svg");for(var s=i[0],o=document.querySelectorAll("[data-source]"),n={video:"video",audio:"audio",youtube:"youtube",vimeo:"vimeo"},r=window.location.hash.replace("#",""),a=window.history&&window.history.pushState,c=o.length-1;c>=0;c--)o[c].addEventListener("click",function(){var e=this.getAttribute("data-source");t(e),a&&history.pushState({type:e},"","#"+e)});if(window.addEventListener("popstate",function(e){e.state&&"type"in e.state&&t(e.state.type)}),a){var l=!r.length;l&&(r=n.video),r in n&&history.replaceState({type:r},"",l?"":"#"+r),r!==n.video&&t(r,!0)}}(),document.domain.indexOf("plyr.io")>-1&&(!function(e,t,i,s,o,n,r){e.GoogleAnalyticsObject=o,e[o]=e[o]||function(){(e[o].q=e[o].q||[]).push(arguments)},e[o].l=1*new Date,n=t.createElement(i),r=t.getElementsByTagName(i)[0],n.async=1,n.src=s,r.parentNode.insertBefore(n,r)}(window,document,"script","//www.google-analytics.com/analytics.js","ga"),ga("create","UA-40881672-11","auto"),ga("send","pageview"));
|
"document"in self&&("classList"in document.createElement("_")?!function(){"use strict";var e=document.createElement("_");if(e.classList.add("c1","c2"),!e.classList.contains("c2")){var t=function(e){var t=DOMTokenList.prototype[e];DOMTokenList.prototype[e]=function(e){var i,s=arguments.length;for(i=0;i<s;i++)e=arguments[i],t.call(this,e)}};t("add"),t("remove")}if(e.classList.toggle("c3",!1),e.classList.contains("c3")){var i=DOMTokenList.prototype.toggle;DOMTokenList.prototype.toggle=function(e,t){return 1 in arguments&&!this.contains(e)==!t?t:i.call(this,e)}}e=null}():!function(e){"use strict";if("Element"in e){var t="classList",i="prototype",s=e.Element[i],o=Object,n=String[i].trim||function(){return this.replace(/^\s+|\s+$/g,"")},r=Array[i].indexOf||function(e){for(var t=0,i=this.length;t<i;t++)if(t in this&&this[t]===e)return t;return-1},a=function(e,t){this.name=e,this.code=DOMException[e],this.message=t},c=function(e,t){if(""===t)throw new a("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(t))throw new a("INVALID_CHARACTER_ERR","String contains an invalid character");return r.call(e,t)},l=function(e){for(var t=n.call(e.getAttribute("class")||""),i=t?t.split(/\s+/):[],s=0,o=i.length;s<o;s++)this.push(i[s]);this._updateClassName=function(){e.setAttribute("class",this.toString())}},u=l[i]=[],d=function(){return new l(this)};if(a[i]=Error[i],u.item=function(e){return this[e]||null},u.contains=function(e){return e+="",c(this,e)!==-1},u.add=function(){var e,t=arguments,i=0,s=t.length,o=!1;do e=t[i]+"",c(this,e)===-1&&(this.push(e),o=!0);while(++i<s);o&&this._updateClassName()},u.remove=function(){var e,t,i=arguments,s=0,o=i.length,n=!1;do for(e=i[s]+"",t=c(this,e);t!==-1;)this.splice(t,1),n=!0,t=c(this,e);while(++s<o);n&&this._updateClassName()},u.toggle=function(e,t){e+="";var i=this.contains(e),s=i?t!==!0&&"remove":t!==!1&&"add";return s&&this[s](e),t===!0||t===!1?t:!i},u.toString=function(){return this.join(" ")},o.defineProperty){var p={get:d,enumerable:!0,configurable:!0};try{o.defineProperty(s,t,p)}catch(e){e.number===-2146823252&&(p.enumerable=!1,o.defineProperty(s,t,p))}}else o[i].__defineGetter__&&s.__defineGetter__(t,d)}}(self)),function(){function e(e,t,i){if(e)if(e.classList)e.classList[i?"add":"remove"](t);else{var s=(" "+e.className+" ").replace(/\s+/g," ").replace(" "+t+" ","");e.className=s+(i?" "+t:"")}}function t(t,i){if(t in n&&(i||t!==r)&&(r.length||t!==n.video)){switch(t){case n.video:s.source({type:"video",title:"View From A Blue Moon",sources:[{src:"https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.mp4",type:"video/mp4"},{src:"https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.webm",type:"video/webm"}],poster:"https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.jpg",tracks:[{kind:"captions",label:"English",srclang:"en",src:"https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.en.vtt",default:!0}]});break;case n.audio:s.source({type:"audio",title:"Kishi Bashi – “It All Began With A Burst”",sources:[{src:"https://cdn.selz.com/plyr/1.5/Kishi_Bashi_-_It_All_Began_With_a_Burst.mp3",type:"audio/mp3"},{src:"https://cdn.selz.com/plyr/1.5/Kishi_Bashi_-_It_All_Began_With_a_Burst.ogg",type:"audio/ogg"}]});break;case n.youtube:s.source({type:"video",title:"View From A Blue Moon",sources:[{src:"bTqVqk7FSmY",type:"youtube"}]});break;case n.vimeo:s.source({type:"video",title:"View From A Blue Moon",sources:[{src:"147865858",type:"vimeo"}]})}r=t;for(var a=o.length-1;a>=0;a--)e(o[a].parentElement,"active",!1);e(document.querySelector('[data-source="'+t+'"]').parentElement,"active",!0)}}var i=plyr.setup({debug:!0,title:"Video demo",iconUrl:"../dist/plyr.svg",tooltips:{controls:!0},captions:{defaultActive:!0}});plyr.loadSprite("dist/demo.svg");for(var s=i[0],o=document.querySelectorAll("[data-source]"),n={video:"video",audio:"audio",youtube:"youtube",vimeo:"vimeo"},r=window.location.hash.replace("#",""),a=window.history&&window.history.pushState,c=o.length-1;c>=0;c--)o[c].addEventListener("click",function(){var e=this.getAttribute("data-source");t(e),a&&history.pushState({type:e},"","#"+e)});if(window.addEventListener("popstate",function(e){e.state&&"type"in e.state&&t(e.state.type)}),a){var l=!r.length;l&&(r=n.video),r in n&&history.replaceState({type:r},"",l?"":"#"+r),r!==n.video&&t(r,!0)}}(),document.domain.indexOf("plyr.io")>-1&&(!function(e,t,i,s,o,n,r){e.GoogleAnalyticsObject=o,e[o]=e[o]||function(){(e[o].q=e[o].q||[]).push(arguments)},e[o].l=1*new Date,n=t.createElement(i),r=t.getElementsByTagName(i)[0],n.async=1,n.src=s,r.parentNode.insertBefore(n,r)}(window,document,"script","//www.google-analytics.com/analytics.js","ga"),ga("create","UA-40881672-11","auto"),ga("send","pageview"));
|
@ -6,7 +6,7 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
<!-- Docs styles -->
|
<!-- Docs styles -->
|
||||||
<link rel="stylesheet" href="dist/docs.css">
|
<link rel="stylesheet" href="dist/demo.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<main>
|
<main>
|
||||||
|
@ -16,11 +16,11 @@
|
|||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
<h1>Plyr</h1>
|
<h1>Plyr</h1>
|
||||||
<p>A simple, accessible HTML5 media player by <a href="https://twitter.com/sam_potts" target="_blank">@sam_potts</a> from <a href="https://twitter.com/selz" target="_blank">@selz</a></p>
|
<p>A simple, accessible HTML5 media player by <a href="https://twitter.com/sam_potts" target="_blank">@sam_potts</a></p>
|
||||||
<nav>
|
<nav>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<a href="https://github.com/selz/plyr" target="_blank" class="btn btn--large btn--primary" data-shr-network="github">
|
<a href="https://github.com/sampotts/plyr" target="_blank" class="btn btn--large btn--primary" data-shr-network="github">
|
||||||
<svg class="icon"><use xlink:href="#icon-github"/></svg>Download on GitHub
|
<svg class="icon"><use xlink:href="#icon-github"/></svg>Download on GitHub
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@ -51,7 +51,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
<section>
|
<section>
|
||||||
<video poster="https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.jpg" controls crossorigin>
|
<video poster="https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.jpg?v1" controls crossorigin>
|
||||||
<!-- Video files -->
|
<!-- Video files -->
|
||||||
<source src="https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.mp4" type="video/mp4">
|
<source src="https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.mp4" type="video/mp4">
|
||||||
<source src="https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.webm" type="video/webm">
|
<source src="https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.webm" type="video/webm">
|
||||||
@ -66,8 +66,8 @@
|
|||||||
<ul>
|
<ul>
|
||||||
<li class="plyr__cite plyr__cite--video"><small><a href="http://viewfromabluemoon.com/" target="_blank">View From A Blue Moon</a> © Brainfarm</small></li>
|
<li class="plyr__cite plyr__cite--video"><small><a href="http://viewfromabluemoon.com/" target="_blank">View From A Blue Moon</a> © Brainfarm</small></li>
|
||||||
<li class="plyr__cite plyr__cite--audio"><small><a href="http://www.kishibashi.com/" target="_blank">Kishi Bashi – “It All Began With A Burst”</a> © Kishi Bashi</small></li>
|
<li class="plyr__cite plyr__cite--audio"><small><a href="http://www.kishibashi.com/" target="_blank">Kishi Bashi – “It All Began With A Burst”</a> © Kishi Bashi</small></li>
|
||||||
<li class="plyr__cite plyr__cite--youtube"><small><a href="https://www.youtube.com/watch?v=bTqVqk7FSmY" target="_blank">View From A Blue Moon</a> on <span class="color--youtube"><svg class="icon"><use xlink:href="#icon-youtube"/></svg>YouTube</span></small>
|
<li class="plyr__cite plyr__cite--youtube"><small><a href="https://www.youtube.com/watch?v=bTqVqk7FSmY" target="_blank">View From A Blue Moon</a> on <span class="color--youtube"><svg class="icon"><use xlink:href="#icon-youtube"/></svg>YouTube</span></small></li>
|
||||||
<li class="plyr__cite plyr__cite--vimeo"><small><a href="https://vimeo.com/ondemand/viewfromabluemoon4k" target="_blank">View From A Blue Moon</a> on <span class="color--vimeo"><svg class="icon"><use xlink:href="#icon-vimeo"/></svg>Vimeo</span></small>
|
<li class="plyr__cite plyr__cite--vimeo"><small><a href="https://vimeo.com/ondemand/viewfromabluemoon4k" target="_blank">View From A Blue Moon</a> on <span class="color--vimeo"><svg class="icon"><use xlink:href="#icon-vimeo"/></svg>Vimeo</span></small></li>
|
||||||
</ul>
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
/*global plyr*/
|
/*global plyr*/
|
||||||
|
|
||||||
// General functions
|
// General functions
|
||||||
;(function() {
|
(function() {
|
||||||
//document.body.addEventListener('ready', function(event) { console.log(event); });
|
//document.body.addEventListener('ready', function(event) { console.log(event); });
|
||||||
|
|
||||||
// Setup the player
|
// Setup the player
|
||||||
@ -94,7 +94,7 @@
|
|||||||
// Set a new source
|
// Set a new source
|
||||||
function newSource(type, init) {
|
function newSource(type, init) {
|
||||||
// Bail if new type isn't known, it's the current type, or current type is empty (video is default) and new type is video
|
// Bail if new type isn't known, it's the current type, or current type is empty (video is default) and new type is video
|
||||||
if(!(type in types) || (!init && type == currentType) || (!currentType.length && type == types.video)) {
|
if(!(type in types) || (!init && type === currentType) || (!currentType.length && type === types.video)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,7 +153,7 @@
|
|||||||
type: 'video',
|
type: 'video',
|
||||||
title: 'View From A Blue Moon',
|
title: 'View From A Blue Moon',
|
||||||
sources: [{
|
sources: [{
|
||||||
src: '143418951',
|
src: '147865858',
|
||||||
type: 'vimeo'
|
type: 'vimeo'
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
2
dist/plyr.css
vendored
2
dist/plyr.css
vendored
File diff suppressed because one or more lines are too long
4
dist/plyr.js
vendored
4
dist/plyr.js
vendored
File diff suppressed because one or more lines are too long
16
gulpfile.js
16
gulpfile.js
@ -245,15 +245,15 @@ options = {
|
|||||||
// If aws is setup
|
// If aws is setup
|
||||||
if("cdn" in aws) {
|
if("cdn" in aws) {
|
||||||
var regex = "(?:0|[1-9][0-9]*)\\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)(?:-[\\da-z\\-]+(?:\.[\\da-z\\-]+)*)?(?:\\+[\\da-z\\-]+(?:\.[\\da-z\\-]+)*)?",
|
var regex = "(?:0|[1-9][0-9]*)\\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)(?:-[\\da-z\\-]+(?:\.[\\da-z\\-]+)*)?(?:\\+[\\da-z\\-]+(?:\.[\\da-z\\-]+)*)?",
|
||||||
cdnpath = new RegExp(aws.cdn.bucket + "\/" + regex, "gi"),
|
cdnpath = new RegExp(aws.cdn.domain + "\/" + regex, "gi"),
|
||||||
semver = new RegExp("v" + regex, "gi"),
|
semver = new RegExp("v" + regex, "gi"),
|
||||||
localPath = new RegExp("(\.\.\/)?dist", "gi"),
|
localPath = new RegExp("(\.\.\/)?dist", "gi"),
|
||||||
versionPath = "https://" + aws.cdn.bucket + "/" + version;
|
versionPath = "https://" + aws.cdn.domain + "/" + version;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Publish version to CDN bucket
|
// Publish version to CDN bucket
|
||||||
gulp.task("cdn", function () {
|
gulp.task("cdn", function () {
|
||||||
console.log("Uploading " + version + " to " + aws.cdn.bucket + "...");
|
console.log("Uploading " + version + " to " + aws.cdn.domain + "...");
|
||||||
|
|
||||||
// Upload to CDN
|
// Upload to CDN
|
||||||
return gulp.src(paths.upload)
|
return gulp.src(paths.upload)
|
||||||
@ -270,17 +270,17 @@ gulp.task("cdn", function () {
|
|||||||
|
|
||||||
// Publish to demo bucket
|
// Publish to demo bucket
|
||||||
gulp.task("demo", function () {
|
gulp.task("demo", function () {
|
||||||
console.log("Uploading " + version + " demo to " + aws.demo.bucket + "...");
|
console.log("Uploading " + version + " demo to " + aws.demo.domain + "...");
|
||||||
|
|
||||||
// Replace versioned files in readme.md
|
// Replace versioned files in readme.md
|
||||||
gulp.src([root + "/readme.md"])
|
gulp.src([root + "/readme.md"])
|
||||||
.pipe(replace(cdnpath, aws.cdn.bucket + "/" + version))
|
.pipe(replace(cdnpath, aws.cdn.domain + "/" + version))
|
||||||
.pipe(gulp.dest(root));
|
.pipe(gulp.dest(root));
|
||||||
|
|
||||||
// Replace versioned files in plyr.js
|
// Replace versioned files in plyr.js
|
||||||
gulp.src(path.join(root, "src/js/plyr.js"))
|
gulp.src(path.join(root, "src/js/plyr.js"))
|
||||||
.pipe(replace(semver, "v" + version))
|
.pipe(replace(semver, "v" + version))
|
||||||
.pipe(replace(cdnpath, aws.cdn.bucket + "/" + version))
|
.pipe(replace(cdnpath, aws.cdn.domain + "/" + version))
|
||||||
.pipe(gulp.dest(path.join(root, "src/js/")));
|
.pipe(gulp.dest(path.join(root, "src/js/")));
|
||||||
|
|
||||||
// Replace local file paths with remote paths in demo HTML
|
// Replace local file paths with remote paths in demo HTML
|
||||||
@ -320,14 +320,14 @@ gulp.task("symlinks", function () {
|
|||||||
|
|
||||||
// Open the demo site to check it's sweet
|
// Open the demo site to check it's sweet
|
||||||
gulp.task("open", function () {
|
gulp.task("open", function () {
|
||||||
console.log("Opening " + aws.demo.bucket + "...");
|
console.log("Opening " + aws.demo.domain + "...");
|
||||||
|
|
||||||
// A file must be specified or gulp will skip the task
|
// A file must be specified or gulp will skip the task
|
||||||
// Doesn't matter which file since we set the URL above
|
// Doesn't matter which file since we set the URL above
|
||||||
// Weird, I know...
|
// Weird, I know...
|
||||||
return gulp.src([paths.demo.root + "index.html"])
|
return gulp.src([paths.demo.root + "index.html"])
|
||||||
.pipe(open("", {
|
.pipe(open("", {
|
||||||
url: "http://" + aws.demo.bucket
|
url: "http://" + aws.demo.domain
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2015 Selz.com
|
Copyright (c) 2017 Sam Potts
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
43
notes.md
Normal file
43
notes.md
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
### Todo
|
||||||
|
|
||||||
|
#### To build
|
||||||
|
[x] Get list of subtitles/captions available (HTML5, Vimeo)
|
||||||
|
[x] Add preferred quality option into config
|
||||||
|
[ ] Update quality options on YouTube play (can't get up front?!)
|
||||||
|
[ ] Update speed options on YouTube load
|
||||||
|
[ ] Finish and test PiP (need MacOS Sierra)
|
||||||
|
[ ] Finish and test AirPlay (need MacOS Sierra)
|
||||||
|
[ ] Controls hide/show events
|
||||||
|
[ ] Test custom controls still works
|
||||||
|
[ ] Tidy up small UI for iOS inline
|
||||||
|
[ ] Finish new loop setup and UI
|
||||||
|
[ ] Toggle settings menu
|
||||||
|
|
||||||
|
#### Later
|
||||||
|
[ ] Get quality options for HTML5 somehow (multi source?)
|
||||||
|
[ ] Download button - grab first <source> or src attribute (or maybe use currentSrc?) for HTML5 and links for embedded players
|
||||||
|
|
||||||
|
#### Bugs
|
||||||
|
[ ] Fix audio setup bug when calling `.setup()` again
|
||||||
|
[ ] Fix events on unsupported devices (iOS, old IE)
|
||||||
|
[x] Fix YouTube rights blocking (origin perhaps?)
|
||||||
|
|
||||||
|
# Notes
|
||||||
|
- No quality HTML5 support (yet)
|
||||||
|
- No Vimeo quality support
|
||||||
|
- No YouTube caption support
|
||||||
|
- Added Vimeo captions support
|
||||||
|
- No PiP or AirPlay for Vimeo/YouTube
|
||||||
|
- Settings won't be supported for custom controls (coming soon, need to work on templating)
|
||||||
|
- Added `playsinline` support for iOS 10
|
||||||
|
- Embed setup now accept an <iframe> as the target element for true progressive enhancement
|
||||||
|
|
||||||
|
#### Breaking changes
|
||||||
|
- New config options for loop
|
||||||
|
- Selectors changes (new `input` and `display` object) - DOCUMENT
|
||||||
|
- Custom HTML option now `controls` which accepts a string (HTML), a function (your own template engine) or array (use built in controls)
|
||||||
|
- .setup() is removed in favour of a constructor
|
||||||
|
|
||||||
|
## Added
|
||||||
|
- Seek i8n label
|
||||||
|
- Loop related i8n labels
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "plyr",
|
"name": "plyr",
|
||||||
"version": "2.0.5",
|
"version": "2.0.13",
|
||||||
"description": "A simple, accessible and customizable HTML5, YouTube and Vimeo media player",
|
"description": "A simple, accessible and customizable HTML5, YouTube and Vimeo media player",
|
||||||
"homepage": "http://plyr.io",
|
"homepage": "http://plyr.io",
|
||||||
"main": "src/js/plyr.js",
|
"main": "src/js/plyr.js",
|
||||||
@ -35,11 +35,11 @@
|
|||||||
],
|
],
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git://github.com/selz/plyr.git"
|
"url": "git://github.com/sampotts/plyr.git"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/selz/plyr/issues"
|
"url": "https://github.com/sampotts/plyr/issues"
|
||||||
},
|
},
|
||||||
"directories": {
|
"directories": {
|
||||||
"doc": "readme.md"
|
"doc": "readme.md"
|
||||||
@ -47,5 +47,5 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"author": "Sam Potts <sam@selz.com>"
|
"author": "Sam Potts <sam@potts.es>"
|
||||||
}
|
}
|
||||||
|
104
readme.md
104
readme.md
@ -1,6 +1,8 @@
|
|||||||
# Plyr
|
# Plyr
|
||||||
A simple, accessible and customizable HTML5, YouTube and Vimeo media player.
|
A simple, accessible and customizable HTML5, YouTube and Vimeo media player.
|
||||||
|
|
||||||
|
[Donate to support Plyr](#donate)
|
||||||
|
|
||||||
[Checkout the demo](https://plyr.io)
|
[Checkout the demo](https://plyr.io)
|
||||||
|
|
||||||
[](https://plyr.io)
|
[](https://plyr.io)
|
||||||
@ -30,15 +32,25 @@ Oh and yes, it works with Bootstrap.
|
|||||||
## Changelog
|
## Changelog
|
||||||
Check out the [changelog](changelog.md) to see what's new with Plyr.
|
Check out the [changelog](changelog.md) to see what's new with Plyr.
|
||||||
|
|
||||||
## Planned Development
|
## Features currently being developed
|
||||||
- Playback speed
|
- Playback speed selection
|
||||||
- Quality selection
|
- Quality selection
|
||||||
- Playlists
|
- Caption language selection
|
||||||
- Multiple language captions (with selection)
|
- AirPlay
|
||||||
- Audio captions
|
- Picture in Picture (MacOS Sierra + Safari)
|
||||||
... and whatever else has been raised in [issues](https://github.com/Selz/plyr/issues)
|
|
||||||
|
|
||||||
If you have any cool ideas or features, please let me know by [creating an issue](https://github.com/Selz/plyr/issues/new) or, of course, forking and sending a pull request.
|
[more info](https://github.com/sampotts/plyr/issues?q=is%3Aissue+is%3Aopen+label%3A%22In+Development%22)
|
||||||
|
|
||||||
|
## Planned features
|
||||||
|
- Playlists
|
||||||
|
- Google cast
|
||||||
|
- Facebook video support
|
||||||
|
- Wistia video support
|
||||||
|
- YouTube and Vimeo audio support
|
||||||
|
- Audio captions
|
||||||
|
...and whatever else has been raised in [issues](https://github.com/sampotts/plyr/issues)
|
||||||
|
|
||||||
|
If you have any cool ideas or features, please let me know by [creating an issue](https://github.com/sampotts/plyr/issues/new) or, of course, forking and sending a pull request.
|
||||||
|
|
||||||
## CMS plugins
|
## CMS plugins
|
||||||
|
|
||||||
@ -106,10 +118,13 @@ For YouTube and Vimeo, Plyr uses the standard YouTube API markup (an empty `<div
|
|||||||
<div data-type="youtube" data-video-id="bTqVqk7FSmY"></div>
|
<div data-type="youtube" data-video-id="bTqVqk7FSmY"></div>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Note: `data-video-id` value can now be the ID or URL for the video. This attribute name will change in a future release to reflect this change.
|
||||||
|
|
||||||
#### Vimeo embed
|
#### Vimeo embed
|
||||||
```html
|
```html
|
||||||
<div data-type="vimeo" data-video-id="143418951"></div>
|
<div data-type="vimeo" data-video-id="143418951"></div>
|
||||||
```
|
```
|
||||||
|
Note: `data-video-id` value can now be the ID or URL for the video. This attribute name will change in a future release to reflect this change.
|
||||||
|
|
||||||
### JavaScript
|
### JavaScript
|
||||||
Include the `plyr.js` script before the closing `</body>` tag and then call `plyr.setup()`. More info on `setup()` can be found under [initialising](#initialising).
|
Include the `plyr.js` script before the closing `</body>` tag and then call `plyr.setup()`. More info on `setup()` can be found under [initialising](#initialising).
|
||||||
@ -119,10 +134,10 @@ Include the `plyr.js` script before the closing `</body>` tag and then call `ply
|
|||||||
<script>plyr.setup();</script>
|
<script>plyr.setup();</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
If you want to use our CDN for the JavaScript, you can use the following:
|
If you want to use our CDN (provided by [Fastly](https://www.fastly.com/)) for the JavaScript, you can use the following:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<script src="https://cdn.plyr.io/2.0.5/plyr.js"></script>
|
<script src="https://cdn.plyr.io/2.0.13/plyr.js"></script>
|
||||||
```
|
```
|
||||||
|
|
||||||
### CSS
|
### CSS
|
||||||
@ -132,14 +147,14 @@ Include the `plyr.css` stylsheet into your `<head>`
|
|||||||
<link rel="stylesheet" href="path/to/plyr.css">
|
<link rel="stylesheet" href="path/to/plyr.css">
|
||||||
```
|
```
|
||||||
|
|
||||||
If you want to use our CDN for the default CSS, you can use the following:
|
If you want to use our CDN (provided by [Fastly](https://www.fastly.com/)) for the default CSS, you can use the following:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<link rel="stylesheet" href="https://cdn.plyr.io/2.0.5/plyr.css">
|
<link rel="stylesheet" href="https://cdn.plyr.io/2.0.13/plyr.css">
|
||||||
```
|
```
|
||||||
|
|
||||||
### SVG Sprite
|
### SVG Sprite
|
||||||
The SVG sprite is loaded automatically from our CDN. To change this, see the [options](#Options) below. For reference, the CDN hosted SVG sprite can be found at `https://cdn.plyr.io/2.0.5/plyr.svg`.
|
The SVG sprite is loaded automatically from our CDN (provided by [Fastly](https://www.fastly.com/)). To change this, see the [options](#options) below. For reference, the CDN hosted SVG sprite can be found at `https://cdn.plyr.io/2.0.13/plyr.svg`.
|
||||||
|
|
||||||
## Advanced
|
## Advanced
|
||||||
|
|
||||||
@ -271,6 +286,12 @@ Note the single quotes encapsulating the JSON and double quotes on the object ke
|
|||||||
<td><code>plyr</code></td>
|
<td><code>plyr</code></td>
|
||||||
<td>Specify the id prefix for the icons used in the default controls (e.g. "plyr-play" would be "plyr"). This is to prevent clashes if you're using your own SVG sprite but with the default controls. Most people can ignore this option.</td>
|
<td>Specify the id prefix for the icons used in the default controls (e.g. "plyr-play" would be "plyr"). This is to prevent clashes if you're using your own SVG sprite but with the default controls. Most people can ignore this option.</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>blankUrl</code></td>
|
||||||
|
<td>String</td>
|
||||||
|
<td><code>https://cdn.selz.com/plyr/blank.mp4</code></td>
|
||||||
|
<td>Specify a URL or path to a blank video file used to properly cancel network requests. See <a href="https://github.com/sampotts/plyr/issues/174">issue #174</a> for more info.</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>debug</code></td>
|
<td><code>debug</code></td>
|
||||||
<td>Boolean</td>
|
<td>Boolean</td>
|
||||||
@ -492,7 +513,7 @@ Here's a list of the methods supported:
|
|||||||
<tr>
|
<tr>
|
||||||
<td><code>on()</code></td>
|
<td><code>on()</code></td>
|
||||||
<td>String, Function</td>
|
<td>String, Function</td>
|
||||||
<td>Watch for an event (first argument) and run a callback function (second argument). This saves you doing your own <code>addEventListner</code> code.</td>
|
<td>Watch for an event (first argument) and run a callback function (second argument). This saves you doing your own <code>addEventListner</code> code. This is chainable.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>play()</code></td>
|
<td><code>play()</code></td>
|
||||||
@ -529,6 +550,26 @@ Here's a list of the methods supported:
|
|||||||
<td>Number</td>
|
<td>Number</td>
|
||||||
<td>Seeks the media to the provided parameter, time in seconds.</td>
|
<td>Seeks the media to the provided parameter, time in seconds.</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>getCurrentTime()</code></td>
|
||||||
|
<td>—</td>
|
||||||
|
<td>Will return a float with the current time in seconds.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>getDuration()</code></td>
|
||||||
|
<td>—</td>
|
||||||
|
<td>Will return a float with the duration in seconds.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>getVolume()</code></td>
|
||||||
|
<td>—</td>
|
||||||
|
<td>Will return a float between 0 and 1 for the current volume level.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>isMuted()</code></td>
|
||||||
|
<td>—</td>
|
||||||
|
<td>Will return a boolean for whether the media is currently muted.</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>setVolume(...)</code></td>
|
<td><code>setVolume(...)</code></td>
|
||||||
<td>Number</td>
|
<td>Number</td>
|
||||||
@ -539,6 +580,11 @@ Here's a list of the methods supported:
|
|||||||
<td>Boolean</td>
|
<td>Boolean</td>
|
||||||
<td>Toggles playback for the player based on either the boolean argument or it's current state.</td>
|
<td>Toggles playback for the player based on either the boolean argument or it's current state.</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>isPaused()</code></td>
|
||||||
|
<td>—</td>
|
||||||
|
<td>Will return a boolean for whether the media is currently paused.</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>toggleMute()</code></td>
|
<td><code>toggleMute()</code></td>
|
||||||
<td>—</td>
|
<td>—</td>
|
||||||
@ -590,11 +636,6 @@ Here's a list of the methods supported:
|
|||||||
<td>—</td>
|
<td>—</td>
|
||||||
<td>Restores the original element, reversing the effects of <code>setup()</code>.</td>
|
<td>Restores the original element, reversing the effects of <code>setup()</code>.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td><code>getCurrentTime()</code></td>
|
|
||||||
<td>—</td>
|
|
||||||
<td>Will return a float with the current time in seconds.</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
@ -656,6 +697,8 @@ player.source({
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Note: `src` can be the video ID or URL
|
||||||
|
|
||||||
Vimeo example
|
Vimeo example
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
@ -669,7 +712,9 @@ player.source({
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
Some more details on the object parameters
|
Note: `src` can be the video ID or URL
|
||||||
|
|
||||||
|
More details on the object parameters
|
||||||
|
|
||||||
<table class="table" width="100%">
|
<table class="table" width="100%">
|
||||||
<thead>
|
<thead>
|
||||||
@ -693,7 +738,7 @@ Some more details on the object parameters
|
|||||||
<tr>
|
<tr>
|
||||||
<td><code>sources</code></td>
|
<td><code>sources</code></td>
|
||||||
<td>Array</td>
|
<td>Array</td>
|
||||||
<td>This is an array of sources. <code>type</code> is optional for YouTube and Vimeo when specifying an array. For YouTube and Vimeo media, only the video ID must be passed as the source as shown above. The keys of this object are mapped directly to HTML attributes so more can be added to the object if required.</td>
|
<td>This is an array of sources. <code>type</code> is optional for YouTube and Vimeo when specifying an array. For YouTube and Vimeo media, the video ID or URL must be passed as the source as shown above. The keys of this object are mapped directly to HTML attributes so more can be added to the object if required.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>poster</code></td>
|
<td><code>poster</code></td>
|
||||||
@ -756,7 +801,7 @@ These events also bubble up the DOM. The event target will be the container elem
|
|||||||
<tr>
|
<tr>
|
||||||
<td><code>ended</code></td>
|
<td><code>ended</code></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>Sent when playback completes.</td>
|
<td>Sent when playback completes. Note: with Vimeo this does not occur if `loop` is enabled.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>error</code></td>
|
<td><code>error</code></td>
|
||||||
@ -800,12 +845,12 @@ These events also bubble up the DOM. The event target will be the container elem
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>seeked</code></td>
|
<td><code>seeked</code></td>
|
||||||
<td>✔</td>
|
<td></td>
|
||||||
<td>Sent when a seek operation completes.</td>
|
<td>Sent when a seek operation completes.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>seeking</code></td>
|
<td><code>seeking</code></td>
|
||||||
<td>✔</td>
|
<td></td>
|
||||||
<td>Sent when a seek operation begins.</td>
|
<td>Sent when a seek operation begins.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -976,7 +1021,7 @@ Fullscreen in Plyr is supported by all browsers that [currently support it](http
|
|||||||
|
|
||||||
² Native player used (no support for `<progress>` or `<input type="range">`) but the API is supported (v1.0.28+)
|
² Native player used (no support for `<progress>` or `<input type="range">`) but the API is supported (v1.0.28+)
|
||||||
|
|
||||||
³ IE10 has no native fullscreen support, fallback can be used (see options)
|
³ IE10 has no native fullscreen support, fallback can be used (see [options](#options))
|
||||||
|
|
||||||
The `enabled` option can be used to disable certain User Agents. For example, if you don't want to use Plyr for smartphones, you could use:
|
The `enabled` option can be used to disable certain User Agents. For example, if you don't want to use Plyr for smartphones, you could use:
|
||||||
|
|
||||||
@ -994,7 +1039,11 @@ There's an API method for checking support. You can call `plyr.supported()` and
|
|||||||
If you find anything weird with Plyr, please let us know using the GitHub issues tracker.
|
If you find anything weird with Plyr, please let us know using the GitHub issues tracker.
|
||||||
|
|
||||||
## Author
|
## Author
|
||||||
Plyr is developed by [@sam_potts](https://twitter.com/sam_potts) / [sampotts.me](http://sampotts.me) with help from the awesome [contributors](https://github.com/Selz/plyr/graphs/contributors)
|
Plyr is developed by [@sam_potts](https://twitter.com/sam_potts) / [sampotts.me](http://sampotts.me) with help from the awesome [contributors](https://github.com/sampotts/plyr/graphs/contributors)
|
||||||
|
|
||||||
|
## Donate
|
||||||
|
Plyr costs money to run, not my time - I donate that for free but domains, hosting and more. Any help is appreciated...
|
||||||
|
[Donate to support Plyr](https://www.paypal.me/pottsy/20usd)
|
||||||
|
|
||||||
## Mentions
|
## Mentions
|
||||||
- [ProductHunt](https://www.producthunt.com/tech/plyr)
|
- [ProductHunt](https://www.producthunt.com/tech/plyr)
|
||||||
@ -1030,5 +1079,10 @@ Also these links helped created Plyr:
|
|||||||
- [Media Events - W3.org](http://www.w3.org/2010/05/video/mediaevents.html)
|
- [Media Events - W3.org](http://www.w3.org/2010/05/video/mediaevents.html)
|
||||||
- [Styling the `<progress>` element - hongkiat.com](http://www.hongkiat.com/blog/html5-progress-bar/)
|
- [Styling the `<progress>` element - hongkiat.com](http://www.hongkiat.com/blog/html5-progress-bar/)
|
||||||
|
|
||||||
|
## Thanks
|
||||||
|
[](https://www.fastly.com/)
|
||||||
|
|
||||||
|
Thanks to [Fastly](https://www.fastly.com/) for providing the CDN services.
|
||||||
|
|
||||||
## Copyright and License
|
## Copyright and License
|
||||||
[The MIT license](license.md).
|
[The MIT license](license.md).
|
||||||
|
394
src/js/plyr.js
394
src/js/plyr.js
@ -1,7 +1,7 @@
|
|||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
// Plyr
|
// Plyr
|
||||||
// plyr.js v2.0.5
|
// plyr.js v2.0.13
|
||||||
// https://github.com/selz/plyr
|
// https://github.com/sampotts/plyr
|
||||||
// License: The MIT License (MIT)
|
// License: The MIT License (MIT)
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
// Credits: http://paypal.github.io/accessible-html5-video-player/
|
// Credits: http://paypal.github.io/accessible-html5-video-player/
|
||||||
@ -16,7 +16,7 @@
|
|||||||
module.exports = factory(root, document);
|
module.exports = factory(root, document);
|
||||||
} else if (typeof define === 'function' && define.amd) {
|
} else if (typeof define === 'function' && define.amd) {
|
||||||
// AMD
|
// AMD
|
||||||
define(null, function() { factory(root, document) });
|
define([], function () { return factory(root, document); });
|
||||||
} else {
|
} else {
|
||||||
// Browser globals (root is window)
|
// Browser globals (root is window)
|
||||||
root.plyr = factory(root, document);
|
root.plyr = factory(root, document);
|
||||||
@ -43,7 +43,8 @@
|
|||||||
displayDuration: true,
|
displayDuration: true,
|
||||||
loadSprite: true,
|
loadSprite: true,
|
||||||
iconPrefix: 'plyr',
|
iconPrefix: 'plyr',
|
||||||
iconUrl: 'https://cdn.plyr.io/2.0.5/plyr.svg',
|
iconUrl: 'https://cdn.plyr.io/2.0.13/plyr.svg',
|
||||||
|
blankUrl: 'https://cdn.selz.com/plyr/blank.mp4',
|
||||||
clickToPlay: true,
|
clickToPlay: true,
|
||||||
hideControls: true,
|
hideControls: true,
|
||||||
showPosterOnEnd: false,
|
showPosterOnEnd: false,
|
||||||
@ -175,7 +176,7 @@
|
|||||||
fullscreen: null
|
fullscreen: null
|
||||||
},
|
},
|
||||||
// Events to watch on HTML5 media elements
|
// Events to watch on HTML5 media elements
|
||||||
events: ['ready', 'ended', 'progress', 'stalled', 'playing', 'waiting', 'canplay', 'canplaythrough', 'loadstart', 'loadeddata', 'loadedmetadata', 'timeupdate', 'volumechange', 'play', 'pause', 'error', 'seeking', 'emptied'],
|
events: ['ready', 'ended', 'progress', 'stalled', 'playing', 'waiting', 'canplay', 'canplaythrough', 'loadstart', 'loadeddata', 'loadedmetadata', 'timeupdate', 'volumechange', 'play', 'pause', 'error', 'seeking', 'seeked', 'emptied'],
|
||||||
// Logging
|
// Logging
|
||||||
logPrefix: '[Plyr]'
|
logPrefix: '[Plyr]'
|
||||||
};
|
};
|
||||||
@ -195,41 +196,36 @@
|
|||||||
isChrome = false,
|
isChrome = false,
|
||||||
isSafari = false;
|
isSafari = false;
|
||||||
|
|
||||||
// MSIE 11
|
|
||||||
if ((navigator.appVersion.indexOf('Windows NT') !== -1) && (navigator.appVersion.indexOf('rv:11') !== -1)) {
|
if ((navigator.appVersion.indexOf('Windows NT') !== -1) && (navigator.appVersion.indexOf('rv:11') !== -1)) {
|
||||||
|
// MSIE 11
|
||||||
isIE = true;
|
isIE = true;
|
||||||
name = 'IE';
|
name = 'IE';
|
||||||
fullVersion = '11';
|
fullVersion = '11';
|
||||||
}
|
} else if ((verOffset = ua.indexOf('MSIE')) !== -1) {
|
||||||
// MSIE
|
// MSIE
|
||||||
else if ((verOffset = ua.indexOf('MSIE')) !== -1) {
|
|
||||||
isIE = true;
|
isIE = true;
|
||||||
name = 'IE';
|
name = 'IE';
|
||||||
fullVersion = ua.substring(verOffset + 5);
|
fullVersion = ua.substring(verOffset + 5);
|
||||||
}
|
} else if ((verOffset = ua.indexOf('Chrome')) !== -1) {
|
||||||
// Chrome
|
// Chrome
|
||||||
else if ((verOffset = ua.indexOf('Chrome')) !== -1) {
|
|
||||||
isChrome = true;
|
isChrome = true;
|
||||||
name = 'Chrome';
|
name = 'Chrome';
|
||||||
fullVersion = ua.substring(verOffset + 7);
|
fullVersion = ua.substring(verOffset + 7);
|
||||||
}
|
} else if ((verOffset = ua.indexOf('Safari')) !== -1) {
|
||||||
// Safari
|
// Safari
|
||||||
else if ((verOffset = ua.indexOf('Safari')) !== -1) {
|
|
||||||
isSafari = true;
|
isSafari = true;
|
||||||
name = 'Safari';
|
name = 'Safari';
|
||||||
fullVersion = ua.substring(verOffset + 7);
|
fullVersion = ua.substring(verOffset + 7);
|
||||||
if ((verOffset = ua.indexOf('Version')) !== -1) {
|
if ((verOffset = ua.indexOf('Version')) !== -1) {
|
||||||
fullVersion = ua.substring(verOffset + 8);
|
fullVersion = ua.substring(verOffset + 8);
|
||||||
}
|
}
|
||||||
}
|
} else if ((verOffset = ua.indexOf('Firefox')) !== -1) {
|
||||||
// Firefox
|
// Firefox
|
||||||
else if ((verOffset = ua.indexOf('Firefox')) !== -1) {
|
|
||||||
isFirefox = true;
|
isFirefox = true;
|
||||||
name = 'Firefox';
|
name = 'Firefox';
|
||||||
fullVersion = ua.substring(verOffset + 8);
|
fullVersion = ua.substring(verOffset + 8);
|
||||||
}
|
} else if ((nameOffset = ua.lastIndexOf(' ') + 1) < (verOffset = ua.lastIndexOf('/'))) {
|
||||||
// In most other browsers, 'name/version' is at the end of userAgent
|
// In most other browsers, 'name/version' is at the end of userAgent
|
||||||
else if ((nameOffset = ua.lastIndexOf(' ') + 1) < (verOffset = ua.lastIndexOf('/'))) {
|
|
||||||
name = ua.substring(nameOffset,verOffset);
|
name = ua.substring(nameOffset,verOffset);
|
||||||
fullVersion = ua.substring(verOffset + 1);
|
fullVersion = ua.substring(verOffset + 1);
|
||||||
|
|
||||||
@ -262,6 +258,7 @@
|
|||||||
isChrome: isChrome,
|
isChrome: isChrome,
|
||||||
isSafari: isSafari,
|
isSafari: isSafari,
|
||||||
isIos: /(iPad|iPhone|iPod)/g.test(navigator.platform),
|
isIos: /(iPad|iPhone|iPod)/g.test(navigator.platform),
|
||||||
|
isIphone: /(iPhone|iPod)/g.test(navigator.userAgent),
|
||||||
isTouch: 'ontouchstart' in document.documentElement
|
isTouch: 'ontouchstart' in document.documentElement
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -272,7 +269,6 @@
|
|||||||
function _supportMime(plyr, mimeType) {
|
function _supportMime(plyr, mimeType) {
|
||||||
var media = plyr.media;
|
var media = plyr.media;
|
||||||
|
|
||||||
// Only check video types for video players
|
|
||||||
if (plyr.type === 'video') {
|
if (plyr.type === 'video') {
|
||||||
// Check type
|
// Check type
|
||||||
switch (mimeType) {
|
switch (mimeType) {
|
||||||
@ -280,10 +276,7 @@
|
|||||||
case 'video/mp4': return !!(media.canPlayType && media.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"').replace(/no/, ''));
|
case 'video/mp4': return !!(media.canPlayType && media.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"').replace(/no/, ''));
|
||||||
case 'video/ogg': return !!(media.canPlayType && media.canPlayType('video/ogg; codecs="theora"').replace(/no/, ''));
|
case 'video/ogg': return !!(media.canPlayType && media.canPlayType('video/ogg; codecs="theora"').replace(/no/, ''));
|
||||||
}
|
}
|
||||||
}
|
} else if (plyr.type === 'audio') {
|
||||||
|
|
||||||
// Only check audio types for audio players
|
|
||||||
else if (plyr.type === 'audio') {
|
|
||||||
// Check type
|
// Check type
|
||||||
switch (mimeType) {
|
switch (mimeType) {
|
||||||
case 'audio/mpeg': return !!(media.canPlayType && media.canPlayType('audio/mpeg;').replace(/no/, ''));
|
case 'audio/mpeg': return !!(media.canPlayType && media.canPlayType('audio/mpeg;').replace(/no/, ''));
|
||||||
@ -344,8 +337,7 @@
|
|||||||
// append it to the parent.
|
// append it to the parent.
|
||||||
if (sibling) {
|
if (sibling) {
|
||||||
parent.insertBefore(child, sibling);
|
parent.insertBefore(child, sibling);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
parent.appendChild(child);
|
parent.appendChild(child);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -410,8 +402,7 @@
|
|||||||
if (element) {
|
if (element) {
|
||||||
if (element.classList) {
|
if (element.classList) {
|
||||||
element.classList[state ? 'add' : 'remove'](className);
|
element.classList[state ? 'add' : 'remove'](className);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
var name = (' ' + element.className + ' ').replace(/\s+/g, ' ').replace(' ' + className + ' ', '');
|
var name = (' ' + element.className + ' ').replace(/\s+/g, ' ').replace(' ' + className + ' ', '');
|
||||||
element.className = name + (state ? ' ' + className : '');
|
element.className = name + (state ? ' ' + className : '');
|
||||||
}
|
}
|
||||||
@ -423,8 +414,7 @@
|
|||||||
if (element) {
|
if (element) {
|
||||||
if (element.classList) {
|
if (element.classList) {
|
||||||
return element.classList.contains(className);
|
return element.classList.contains(className);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return new RegExp('(\\s|^)' + className + '(\\s|$)').test(element.className);
|
return new RegExp('(\\s|^)' + className + '(\\s|$)').test(element.className);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -568,8 +558,7 @@
|
|||||||
if (source[property] && source[property].constructor && source[property].constructor === Object) {
|
if (source[property] && source[property].constructor && source[property].constructor === Object) {
|
||||||
destination[property] = destination[property] || {};
|
destination[property] = destination[property] || {};
|
||||||
_extend(destination[property], source[property]);
|
_extend(destination[property], source[property]);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
destination[property] = source[property];
|
destination[property] = source[property];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -609,6 +598,18 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Parse YouTube ID from url
|
||||||
|
function _parseYouTubeId(url) {
|
||||||
|
var regex = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/;
|
||||||
|
return (url.match(regex)) ? RegExp.$2 : url;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse Vimeo ID from url
|
||||||
|
function _parseVimeoId(url) {
|
||||||
|
var regex = /^.*(vimeo.com\/|video\/)(\d+).*/;
|
||||||
|
return (url.match(regex)) ? RegExp.$2 : url;
|
||||||
|
}
|
||||||
|
|
||||||
// Fullscreen API
|
// Fullscreen API
|
||||||
function _fullscreen() {
|
function _fullscreen() {
|
||||||
var fullscreen = {
|
var fullscreen = {
|
||||||
@ -625,8 +626,7 @@
|
|||||||
// Check for native support
|
// Check for native support
|
||||||
if (!_is.undefined(document.cancelFullScreen)) {
|
if (!_is.undefined(document.cancelFullScreen)) {
|
||||||
fullscreen.supportsFullScreen = true;
|
fullscreen.supportsFullScreen = true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// Check for fullscreen support by vendor prefix
|
// Check for fullscreen support by vendor prefix
|
||||||
for (var i = 0, il = browserPrefixes.length; i < il; i++ ) {
|
for (var i = 0, il = browserPrefixes.length; i < il; i++ ) {
|
||||||
fullscreen.prefix = browserPrefixes[i];
|
fullscreen.prefix = browserPrefixes[i];
|
||||||
@ -634,9 +634,8 @@
|
|||||||
if (!_is.undefined(document[fullscreen.prefix + 'CancelFullScreen'])) {
|
if (!_is.undefined(document[fullscreen.prefix + 'CancelFullScreen'])) {
|
||||||
fullscreen.supportsFullScreen = true;
|
fullscreen.supportsFullScreen = true;
|
||||||
break;
|
break;
|
||||||
}
|
} else if (!_is.undefined(document.msExitFullscreen) && document.msFullscreenEnabled) {
|
||||||
// Special case for MS (when isn't it?)
|
// Special case for MS (when isn't it?)
|
||||||
else if (!_is.undefined(document.msExitFullscreen) && document.msFullscreenEnabled) {
|
|
||||||
fullscreen.prefix = 'ms';
|
fullscreen.prefix = 'ms';
|
||||||
fullscreen.supportsFullScreen = true;
|
fullscreen.supportsFullScreen = true;
|
||||||
break;
|
break;
|
||||||
@ -688,7 +687,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Try to use it (it might be disabled, e.g. user is in private/porn mode)
|
// Try to use it (it might be disabled, e.g. user is in private/porn mode)
|
||||||
// see: https://github.com/Selz/plyr/issues/131
|
// see: https://github.com/sampotts/plyr/issues/131
|
||||||
try {
|
try {
|
||||||
// Add test item
|
// Add test item
|
||||||
window.localStorage.setItem('___test', 'OK');
|
window.localStorage.setItem('___test', 'OK');
|
||||||
@ -922,8 +921,7 @@
|
|||||||
|
|
||||||
// Add styling hook
|
// Add styling hook
|
||||||
_toggleClass(plyr.container, config.classes.fullscreen.enabled, true);
|
_toggleClass(plyr.container, config.classes.fullscreen.enabled, true);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
_log('Fullscreen not supported and fallback disabled');
|
_log('Fullscreen not supported and fallback disabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -974,17 +972,14 @@
|
|||||||
if (captionSrc === '') {
|
if (captionSrc === '') {
|
||||||
plyr.captionExists = false;
|
plyr.captionExists = false;
|
||||||
_log('No caption track found');
|
_log('No caption track found');
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
_log('Caption track found; URI: ' + captionSrc);
|
_log('Caption track found; URI: ' + captionSrc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no caption file exists, hide container for caption text
|
// If no caption file exists, hide container for caption text
|
||||||
if (!plyr.captionExists) {
|
if (!plyr.captionExists) {
|
||||||
_toggleClass(plyr.container, config.classes.captions.enabled);
|
_toggleClass(plyr.container, config.classes.captions.enabled);
|
||||||
}
|
} else {
|
||||||
// If caption file exists, process captions
|
|
||||||
else {
|
|
||||||
// Turn off native caption rendering to avoid double captions
|
// Turn off native caption rendering to avoid double captions
|
||||||
// This doesn't seem to work in Safari 7+, so the <track> elements are removed from the dom below
|
// This doesn't seem to work in Safari 7+, so the <track> elements are removed from the dom below
|
||||||
var tracks = plyr.media.textTracks;
|
var tracks = plyr.media.textTracks;
|
||||||
@ -1020,16 +1015,14 @@
|
|||||||
// Display a cue, if there is one
|
// Display a cue, if there is one
|
||||||
if (this.activeCues[0] && 'text' in this.activeCues[0]) {
|
if (this.activeCues[0] && 'text' in this.activeCues[0]) {
|
||||||
_setCaption(this.activeCues[0].getCueAsHTML());
|
_setCaption(this.activeCues[0].getCueAsHTML());
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
_setCaption();
|
_setCaption();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
// Caption tracks not natively supported
|
// Caption tracks not natively supported
|
||||||
else {
|
|
||||||
_log('TextTracks not supported so rendering captions manually');
|
_log('TextTracks not supported so rendering captions manually');
|
||||||
|
|
||||||
// Render captions from array at appropriate time
|
// Render captions from array at appropriate time
|
||||||
@ -1047,14 +1040,25 @@
|
|||||||
caption,
|
caption,
|
||||||
req = xhr.responseText;
|
req = xhr.responseText;
|
||||||
|
|
||||||
captions = req.split('\n\n');
|
//According to webvtt spec, line terminator consists of one of the following
|
||||||
|
// CRLF (U+000D U+000A), LF (U+000A) or CR (U+000D)
|
||||||
|
var lineSeparator = '\r\n';
|
||||||
|
if(req.indexOf(lineSeparator+lineSeparator) === -1) {
|
||||||
|
if(req.indexOf('\r\r') !== -1){
|
||||||
|
lineSeparator = '\r';
|
||||||
|
} else {
|
||||||
|
lineSeparator = '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
captions = req.split(lineSeparator+lineSeparator);
|
||||||
|
|
||||||
for (var r = 0; r < captions.length; r++) {
|
for (var r = 0; r < captions.length; r++) {
|
||||||
caption = captions[r];
|
caption = captions[r];
|
||||||
plyr.captions[r] = [];
|
plyr.captions[r] = [];
|
||||||
|
|
||||||
// Get the parts of the captions
|
// Get the parts of the captions
|
||||||
var parts = caption.split('\n'),
|
var parts = caption.split(lineSeparator),
|
||||||
index = 0;
|
index = 0;
|
||||||
|
|
||||||
// Incase caption numbers are added
|
// Incase caption numbers are added
|
||||||
@ -1069,8 +1073,7 @@
|
|||||||
plyr.captions.shift();
|
plyr.captions.shift();
|
||||||
|
|
||||||
_log('Successfully loaded the caption file via AJAX');
|
_log('Successfully loaded the caption file via AJAX');
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
_warn(config.logPrefix + 'There was a problem loading the caption file via AJAX');
|
_warn(config.logPrefix + 'There was a problem loading the caption file via AJAX');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1101,8 +1104,7 @@
|
|||||||
// Set the span content
|
// Set the span content
|
||||||
if (_is.string(caption)) {
|
if (_is.string(caption)) {
|
||||||
content.innerHTML = caption.trim();
|
content.innerHTML = caption.trim();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
content.appendChild(caption);
|
content.appendChild(caption);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1136,8 +1138,7 @@
|
|||||||
function _subTcSecs(tc) {
|
function _subTcSecs(tc) {
|
||||||
if (tc === null || tc === undefined) {
|
if (tc === null || tc === undefined) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
var tc1 = [],
|
var tc1 = [],
|
||||||
tc2 = [],
|
tc2 = [],
|
||||||
seconds;
|
seconds;
|
||||||
@ -1181,8 +1182,7 @@
|
|||||||
|
|
||||||
// Render the caption
|
// Render the caption
|
||||||
_setCaption(plyr.currentCaption);
|
_setCaption(plyr.currentCaption);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
_setCaption();
|
_setCaption();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1239,13 +1239,12 @@
|
|||||||
function _checkFocus(event) {
|
function _checkFocus(event) {
|
||||||
// If it is TAB
|
// If it is TAB
|
||||||
if (event.which === 9 && plyr.isFullscreen) {
|
if (event.which === 9 && plyr.isFullscreen) {
|
||||||
// Move focus to first element that can be tabbed if Shift isn't used
|
|
||||||
if (event.target === last && !event.shiftKey) {
|
if (event.target === last && !event.shiftKey) {
|
||||||
|
// Move focus to first element that can be tabbed if Shift isn't used
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
first.focus();
|
first.focus();
|
||||||
}
|
} else if (event.target === first && event.shiftKey) {
|
||||||
// Move focus to last element that can be tabbed if Shift is used
|
// Move focus to last element that can be tabbed if Shift is used
|
||||||
else if (event.target === first && event.shiftKey) {
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
last.focus();
|
last.focus();
|
||||||
}
|
}
|
||||||
@ -1260,8 +1259,7 @@
|
|||||||
function _insertChildElements(type, attributes) {
|
function _insertChildElements(type, attributes) {
|
||||||
if (_is.string(attributes)) {
|
if (_is.string(attributes)) {
|
||||||
_insertElement(type, plyr.media, { src: attributes });
|
_insertElement(type, plyr.media, { src: attributes });
|
||||||
}
|
} else if (attributes.constructor === Array) {
|
||||||
else if (attributes.constructor === Array) {
|
|
||||||
for (var i = attributes.length - 1; i >= 0; i--) {
|
for (var i = attributes.length - 1; i >= 0; i--) {
|
||||||
_insertElement(type, plyr.media, attributes[i]);
|
_insertElement(type, plyr.media, attributes[i]);
|
||||||
}
|
}
|
||||||
@ -1278,8 +1276,7 @@
|
|||||||
if (iconUrl.absolute) {
|
if (iconUrl.absolute) {
|
||||||
_log('AJAX loading absolute SVG sprite' + (plyr.browser.isIE ? ' (due to IE)' : ''));
|
_log('AJAX loading absolute SVG sprite' + (plyr.browser.isIE ? ' (due to IE)' : ''));
|
||||||
loadSprite(iconUrl.url, "sprite-plyr");
|
loadSprite(iconUrl.url, "sprite-plyr");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
_log('Sprite will be used as external resource directly');
|
_log('Sprite will be used as external resource directly');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1395,8 +1392,7 @@
|
|||||||
function _toggleNativeControls(toggle) {
|
function _toggleNativeControls(toggle) {
|
||||||
if (toggle && _inArray(config.types.html5, plyr.type)) {
|
if (toggle && _inArray(config.types.html5, plyr.type)) {
|
||||||
plyr.media.setAttribute('controls', '');
|
plyr.media.setAttribute('controls', '');
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
plyr.media.removeAttribute('controls');
|
plyr.media.removeAttribute('controls');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1422,7 +1418,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set iframe title
|
// Set iframe title
|
||||||
// https://github.com/Selz/plyr/issues/124
|
// https://github.com/sampotts/plyr/issues/124
|
||||||
if (_is.htmlElement(iframe)) {
|
if (_is.htmlElement(iframe)) {
|
||||||
iframe.setAttribute('title', config.i18n.frameTitle.replace('{title}', config.title));
|
iframe.setAttribute('title', config.i18n.frameTitle.replace('{title}', config.title));
|
||||||
}
|
}
|
||||||
@ -1439,7 +1435,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Clean up old volume
|
// Clean up old volume
|
||||||
// https://github.com/Selz/plyr/issues/171
|
// https://github.com/sampotts/plyr/issues/171
|
||||||
window.localStorage.removeItem('plyr-volume');
|
window.localStorage.removeItem('plyr-volume');
|
||||||
|
|
||||||
// load value from the current key
|
// load value from the current key
|
||||||
@ -1448,14 +1444,12 @@
|
|||||||
if (!value) {
|
if (!value) {
|
||||||
// Key wasn't set (or had been cleared), move along
|
// Key wasn't set (or had been cleared), move along
|
||||||
return;
|
return;
|
||||||
}
|
} else if (/^\d+(\.\d+)?$/.test(value)) {
|
||||||
else if (/^\d+(\.\d+)?$/.test(value)) {
|
|
||||||
// If value is a number, it's probably volume from an older
|
// If value is a number, it's probably volume from an older
|
||||||
// version of plyr. See: https://github.com/Selz/plyr/pull/313
|
// version of plyr. See: https://github.com/sampotts/plyr/pull/313
|
||||||
// Update the key to be JSON
|
// Update the key to be JSON
|
||||||
_updateStorage({volume: parseFloat(value)});
|
_updateStorage({volume: parseFloat(value)});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// Assume it's JSON from this or a later version of plyr
|
// Assume it's JSON from this or a later version of plyr
|
||||||
plyr.storage = JSON.parse(value);
|
plyr.storage = JSON.parse(value);
|
||||||
}
|
}
|
||||||
@ -1497,7 +1491,7 @@
|
|||||||
_toggleClass(plyr.container, config.classes.stopped, config.autoplay);
|
_toggleClass(plyr.container, config.classes.stopped, config.autoplay);
|
||||||
|
|
||||||
// Add iOS class
|
// Add iOS class
|
||||||
_toggleClass(plyr.ontainer, config.classes.isIos, plyr.browser.isIos);
|
_toggleClass(plyr.container, config.classes.isIos, plyr.browser.isIos);
|
||||||
|
|
||||||
// Add touch class
|
// Add touch class
|
||||||
_toggleClass(plyr.container, config.classes.isTouch, plyr.browser.isTouch);
|
_toggleClass(plyr.container, config.classes.isTouch, plyr.browser.isTouch);
|
||||||
@ -1525,9 +1519,23 @@
|
|||||||
// Setup YouTube/Vimeo
|
// Setup YouTube/Vimeo
|
||||||
function _setupEmbed() {
|
function _setupEmbed() {
|
||||||
var container = document.createElement('div'),
|
var container = document.createElement('div'),
|
||||||
mediaId = plyr.embedId,
|
mediaId,
|
||||||
id = plyr.type + '-' + Math.floor(Math.random() * (10000));
|
id = plyr.type + '-' + Math.floor(Math.random() * (10000));
|
||||||
|
|
||||||
|
// Parse IDs from URLs if supplied
|
||||||
|
switch (plyr.type) {
|
||||||
|
case 'youtube':
|
||||||
|
mediaId = _parseYouTubeId(plyr.embedId);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'vimeo':
|
||||||
|
mediaId = _parseVimeoId(plyr.embedId);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
mediaId = plyr.embedId;
|
||||||
|
}
|
||||||
|
|
||||||
// Remove old containers
|
// Remove old containers
|
||||||
var containers = _getElements('[id^="' + plyr.type + '-"]');
|
var containers = _getElements('[id^="' + plyr.type + '-"]');
|
||||||
for (var i = containers.length - 1; i >= 0; i--) {
|
for (var i = containers.length - 1; i >= 0; i--) {
|
||||||
@ -1538,7 +1546,6 @@
|
|||||||
_toggleClass(plyr.media, config.classes.videoWrapper, true);
|
_toggleClass(plyr.media, config.classes.videoWrapper, true);
|
||||||
_toggleClass(plyr.media, config.classes.embedWrapper, true);
|
_toggleClass(plyr.media, config.classes.embedWrapper, true);
|
||||||
|
|
||||||
// YouTube
|
|
||||||
if (plyr.type === 'youtube') {
|
if (plyr.type === 'youtube') {
|
||||||
// Create the YouTube container
|
// Create the YouTube container
|
||||||
plyr.media.appendChild(container);
|
plyr.media.appendChild(container);
|
||||||
@ -1549,8 +1556,7 @@
|
|||||||
// Setup API
|
// Setup API
|
||||||
if (_is.object(window.YT)) {
|
if (_is.object(window.YT)) {
|
||||||
_youTubeReady(mediaId, container);
|
_youTubeReady(mediaId, container);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// Load the API
|
// Load the API
|
||||||
_injectScript(config.urls.youtube.api);
|
_injectScript(config.urls.youtube.api);
|
||||||
|
|
||||||
@ -1565,14 +1571,11 @@
|
|||||||
window.onYouTubeReadyCallbacks.forEach(function(callback) { callback(); });
|
window.onYouTubeReadyCallbacks.forEach(function(callback) { callback(); });
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
} else if (plyr.type === 'vimeo') {
|
||||||
// Vimeo
|
|
||||||
else if (plyr.type === 'vimeo') {
|
|
||||||
// Vimeo needs an extra div to hide controls on desktop (which has full support)
|
// Vimeo needs an extra div to hide controls on desktop (which has full support)
|
||||||
if (plyr.supported.full) {
|
if (plyr.supported.full) {
|
||||||
plyr.media.appendChild(container);
|
plyr.media.appendChild(container);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
container = plyr.media;
|
container = plyr.media;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1590,14 +1593,11 @@
|
|||||||
_vimeoReady(mediaId, container);
|
_vimeoReady(mediaId, container);
|
||||||
}
|
}
|
||||||
}, 50);
|
}, 50);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
_vimeoReady(mediaId, container);
|
_vimeoReady(mediaId, container);
|
||||||
}
|
}
|
||||||
}
|
} else if (plyr.type === 'soundcloud') {
|
||||||
// Soundcloud
|
// TODO: Currently unsupported and undocumented
|
||||||
// TODO: Currently unsupported and undocumented
|
|
||||||
else if (plyr.type === 'soundcloud') {
|
|
||||||
// Inject the iframe
|
// Inject the iframe
|
||||||
var soundCloud = document.createElement('iframe');
|
var soundCloud = document.createElement('iframe');
|
||||||
|
|
||||||
@ -1752,6 +1752,12 @@
|
|||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
plyr.media.paused = false;
|
plyr.media.paused = false;
|
||||||
|
|
||||||
|
// If we were seeking, fire seeked event
|
||||||
|
if (plyr.media.seeking) {
|
||||||
|
_triggerEvent(plyr.media, 'seeked');
|
||||||
|
}
|
||||||
|
|
||||||
plyr.media.seeking = false;
|
plyr.media.seeking = false;
|
||||||
_triggerEvent(plyr.media, 'play');
|
_triggerEvent(plyr.media, 'play');
|
||||||
_triggerEvent(plyr.media, 'playing');
|
_triggerEvent(plyr.media, 'playing');
|
||||||
@ -1765,6 +1771,14 @@
|
|||||||
_triggerEvent(plyr.media, 'timeupdate');
|
_triggerEvent(plyr.media, 'timeupdate');
|
||||||
}, 100);
|
}, 100);
|
||||||
|
|
||||||
|
// Check duration again due to YouTube bug
|
||||||
|
// https://github.com/sampotts/plyr/issues/374
|
||||||
|
// https://code.google.com/p/gdata-issues/issues/detail?id=8690
|
||||||
|
if (plyr.media.duration !== instance.getDuration()) {
|
||||||
|
plyr.media.duration = instance.getDuration();
|
||||||
|
_triggerEvent(plyr.media, 'durationchange');
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
@ -1835,8 +1849,8 @@
|
|||||||
|
|
||||||
plyr.embed.on('loaded', function() {
|
plyr.embed.on('loaded', function() {
|
||||||
// Fix keyboard focus issues
|
// Fix keyboard focus issues
|
||||||
// https://github.com/Selz/plyr/issues/317
|
// https://github.com/sampotts/plyr/issues/317
|
||||||
if(_is.htmlElement(plyr.embed.element) && plyr.supported.full) {
|
if (_is.htmlElement(plyr.embed.element) && plyr.supported.full) {
|
||||||
plyr.embed.element.setAttribute('tabindex', '-1');
|
plyr.embed.element.setAttribute('tabindex', '-1');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1868,6 +1882,12 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
plyr.embed.on('seeked', function() {
|
||||||
|
plyr.media.seeking = false;
|
||||||
|
_triggerEvent(plyr.media, 'seeked');
|
||||||
|
_triggerEvent(plyr.media, 'play');
|
||||||
|
});
|
||||||
|
|
||||||
plyr.embed.on('ended', function() {
|
plyr.embed.on('ended', function() {
|
||||||
plyr.media.paused = true;
|
plyr.media.paused = true;
|
||||||
_triggerEvent(plyr.media, 'ended');
|
_triggerEvent(plyr.media, 'ended');
|
||||||
@ -1968,12 +1988,9 @@
|
|||||||
toggle = plyr.media.paused;
|
toggle = plyr.media.paused;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Play
|
|
||||||
if (toggle) {
|
if (toggle) {
|
||||||
_play();
|
_play();
|
||||||
}
|
} else {
|
||||||
// Pause
|
|
||||||
else {
|
|
||||||
_pause();
|
_pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2005,12 +2022,9 @@
|
|||||||
paused = plyr.media.paused,
|
paused = plyr.media.paused,
|
||||||
duration = _getDuration();
|
duration = _getDuration();
|
||||||
|
|
||||||
// Explicit position
|
|
||||||
if (_is.number(input)) {
|
if (_is.number(input)) {
|
||||||
targetTime = input;
|
targetTime = input;
|
||||||
}
|
} else if (_is.object(input) && _inArray(['input', 'change'], input.type)) {
|
||||||
// Event
|
|
||||||
else if (_is.object(input) && _inArray(['input', 'change'], input.type)) {
|
|
||||||
// It's the seek slider
|
// It's the seek slider
|
||||||
// Seek to the selected time
|
// Seek to the selected time
|
||||||
targetTime = ((input.target.value / input.target.max) * duration);
|
targetTime = ((input.target.value / input.target.max) * duration);
|
||||||
@ -2019,8 +2033,7 @@
|
|||||||
// Normalise targetTime
|
// Normalise targetTime
|
||||||
if (targetTime < 0) {
|
if (targetTime < 0) {
|
||||||
targetTime = 0;
|
targetTime = 0;
|
||||||
}
|
} else if (targetTime > duration) {
|
||||||
else if (targetTime > duration) {
|
|
||||||
targetTime = duration;
|
targetTime = duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2036,7 +2049,6 @@
|
|||||||
|
|
||||||
// Embeds
|
// Embeds
|
||||||
if (_inArray(config.types.embed, plyr.type)) {
|
if (_inArray(config.types.embed, plyr.type)) {
|
||||||
// YouTube
|
|
||||||
switch(plyr.type) {
|
switch(plyr.type) {
|
||||||
case 'youtube':
|
case 'youtube':
|
||||||
plyr.embed.seekTo(targetTime);
|
plyr.embed.seekTo(targetTime);
|
||||||
@ -2056,11 +2068,14 @@
|
|||||||
_pause();
|
_pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trigger timeupdate for embeds
|
// Trigger timeupdate
|
||||||
_triggerEvent(plyr.media, 'timeupdate');
|
_triggerEvent(plyr.media, 'timeupdate');
|
||||||
|
|
||||||
// Set seeking flag
|
// Set seeking flag
|
||||||
plyr.media.seeking = true;
|
plyr.media.seeking = true;
|
||||||
|
|
||||||
|
// Trigger seeking
|
||||||
|
_triggerEvent(plyr.media, 'seeking');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logging
|
// Logging
|
||||||
@ -2079,7 +2094,7 @@
|
|||||||
mediaDuration = 0;
|
mediaDuration = 0;
|
||||||
|
|
||||||
// Only if duration available
|
// Only if duration available
|
||||||
if(plyr.media.duration !== null && !isNaN(plyr.media.duration)) {
|
if (plyr.media.duration !== null && !isNaN(plyr.media.duration)) {
|
||||||
mediaDuration = plyr.media.duration;
|
mediaDuration = plyr.media.duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2118,19 +2133,16 @@
|
|||||||
// If it's a fullscreen change event, update the UI
|
// If it's a fullscreen change event, update the UI
|
||||||
if (event && event.type === fullscreen.fullScreenEventName) {
|
if (event && event.type === fullscreen.fullScreenEventName) {
|
||||||
plyr.isFullscreen = fullscreen.isFullScreen(plyr.container);
|
plyr.isFullscreen = fullscreen.isFullScreen(plyr.container);
|
||||||
}
|
} else {
|
||||||
// Else it's a user request to enter or exit
|
// Else it's a user request to enter or exit
|
||||||
else {
|
|
||||||
// Request fullscreen
|
|
||||||
if (!fullscreen.isFullScreen(plyr.container)) {
|
if (!fullscreen.isFullScreen(plyr.container)) {
|
||||||
// Save scroll position
|
// Save scroll position
|
||||||
_saveScrollPosition();
|
_saveScrollPosition();
|
||||||
|
|
||||||
// Request full screen
|
// Request full screen
|
||||||
fullscreen.requestFullScreen(plyr.container);
|
fullscreen.requestFullScreen(plyr.container);
|
||||||
}
|
} else {
|
||||||
// Bail from fullscreen
|
// Bail from fullscreen
|
||||||
else {
|
|
||||||
fullscreen.cancelFullScreen();
|
fullscreen.cancelFullScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2139,8 +2151,7 @@
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// Otherwise, it's a simple toggle
|
// Otherwise, it's a simple toggle
|
||||||
plyr.isFullscreen = !plyr.isFullscreen;
|
plyr.isFullscreen = !plyr.isFullscreen;
|
||||||
|
|
||||||
@ -2255,7 +2266,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Toggle muted state
|
// Toggle muted state
|
||||||
if (plyr.media.muted && volume > 0) {
|
if (volume === 0) {
|
||||||
|
plyr.media.muted = true;
|
||||||
|
} else if (plyr.media.muted && volume > 0) {
|
||||||
_toggleMute();
|
_toggleMute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2389,12 +2402,11 @@
|
|||||||
value = (function() {
|
value = (function() {
|
||||||
var buffered = plyr.media.buffered;
|
var buffered = plyr.media.buffered;
|
||||||
|
|
||||||
// HTML5
|
|
||||||
if (buffered && buffered.length) {
|
if (buffered && buffered.length) {
|
||||||
|
// HTML5
|
||||||
return _getPercentage(buffered.end(0), duration);
|
return _getPercentage(buffered.end(0), duration);
|
||||||
}
|
} else if (_is.number(buffered)) {
|
||||||
// YouTube returns between 0 and 1
|
// YouTube returns between 0 and 1
|
||||||
else if (_is.number(buffered)) {
|
|
||||||
return (buffered * 100);
|
return (buffered * 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2423,8 +2435,7 @@
|
|||||||
if (_is.undefined(progress)) {
|
if (_is.undefined(progress)) {
|
||||||
if (plyr.progress && plyr.progress.buffer) {
|
if (plyr.progress && plyr.progress.buffer) {
|
||||||
progress = plyr.progress.buffer;
|
progress = plyr.progress.buffer;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2432,9 +2443,8 @@
|
|||||||
// One progress element passed
|
// One progress element passed
|
||||||
if (_is.htmlElement(progress)) {
|
if (_is.htmlElement(progress)) {
|
||||||
progress.value = value;
|
progress.value = value;
|
||||||
}
|
} else if (progress) {
|
||||||
// Object of progress + text element
|
// Object of progress + text element
|
||||||
else if (progress) {
|
|
||||||
if (progress.bar) {
|
if (progress.bar) {
|
||||||
progress.bar.value = value;
|
progress.bar.value = value;
|
||||||
}
|
}
|
||||||
@ -2547,20 +2557,17 @@
|
|||||||
if (!event) {
|
if (!event) {
|
||||||
if (_hasClass(plyr.progress.tooltip, visible)) {
|
if (_hasClass(plyr.progress.tooltip, visible)) {
|
||||||
percent = plyr.progress.tooltip.style.left.replace('%', '');
|
percent = plyr.progress.tooltip.style.left.replace('%', '');
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
percent = ((100 / clientRect.width) * (event.pageX - clientRect.left));
|
percent = ((100 / clientRect.width) * (event.pageX - clientRect.left));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set bounds
|
// Set bounds
|
||||||
if (percent < 0) {
|
if (percent < 0) {
|
||||||
percent = 0;
|
percent = 0;
|
||||||
}
|
} else if (percent > 100) {
|
||||||
else if (percent > 100) {
|
|
||||||
percent = 100;
|
percent = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2607,8 +2614,7 @@
|
|||||||
if (toggle.type === 'focus') {
|
if (toggle.type === 'focus') {
|
||||||
delay = 3000;
|
delay = 3000;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
show = _hasClass(plyr.container, config.classes.hideControls);
|
show = _hasClass(plyr.container, config.classes.hideControls);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2846,8 +2852,7 @@
|
|||||||
// Get the last play button to account for the large play button
|
// Get the last play button to account for the large play button
|
||||||
if (target && target.length > 1) {
|
if (target && target.length > 1) {
|
||||||
target = target[target.length - 1];
|
target = target[target.length - 1];
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
target = target[0];
|
target = target[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2872,8 +2877,7 @@
|
|||||||
|
|
||||||
if (!focused || focused === document.body) {
|
if (!focused || focused === document.body) {
|
||||||
focused = null;
|
focused = null;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
focused = document.querySelector(':focus');
|
focused = document.querySelector(':focus');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2894,8 +2898,7 @@
|
|||||||
for (var i = 0; i < element.length; i++) {
|
for (var i = 0; i < element.length; i++) {
|
||||||
_toggleClass(element[i], config.classes.tabFocus, (element[i] === focused));
|
_toggleClass(element[i], config.classes.tabFocus, (element[i] === focused));
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
_toggleClass(element, config.classes.tabFocus, (element === focused));
|
_toggleClass(element, config.classes.tabFocus, (element === focused));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3003,8 +3006,7 @@
|
|||||||
|
|
||||||
// Store last code for next cycle
|
// Store last code for next cycle
|
||||||
last = code;
|
last = code;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
last = null;
|
last = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3064,7 +3066,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Captions
|
// Captions
|
||||||
_on(plyr.buttons.captions, 'click', _toggleCaptions);
|
_proxyListener(plyr.buttons.captions, 'click', config.listeners.captions, _toggleCaptions);
|
||||||
|
|
||||||
// Seek tooltip
|
// Seek tooltip
|
||||||
_on(plyr.progress.container, 'mouseenter mouseleave mousemove', _updateSeekTooltip);
|
_on(plyr.progress.container, 'mouseenter mouseleave mousemove', _updateSeekTooltip);
|
||||||
@ -3101,8 +3103,7 @@
|
|||||||
if (event.deltaY < 0 || event.deltaX > 0) {
|
if (event.deltaY < 0 || event.deltaX > 0) {
|
||||||
if (inverted) {
|
if (inverted) {
|
||||||
_decreaseVolume(step);
|
_decreaseVolume(step);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
_increaseVolume(step);
|
_increaseVolume(step);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3111,8 +3112,7 @@
|
|||||||
if (event.deltaY > 0 || event.deltaX < 0) {
|
if (event.deltaY > 0 || event.deltaX < 0) {
|
||||||
if (inverted) {
|
if (inverted) {
|
||||||
_increaseVolume(step);
|
_increaseVolume(step);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
_decreaseVolume(step);
|
_decreaseVolume(step);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3133,7 +3133,7 @@
|
|||||||
// Handle the media finishing
|
// Handle the media finishing
|
||||||
_on(plyr.media, 'ended', function() {
|
_on(plyr.media, 'ended', function() {
|
||||||
// Show poster on end
|
// Show poster on end
|
||||||
if(plyr.type === 'video' && config.showPosterOnEnd) {
|
if (plyr.type === 'video' && config.showPosterOnEnd) {
|
||||||
// Clear
|
// Clear
|
||||||
if (plyr.type === 'video') {
|
if (plyr.type === 'video') {
|
||||||
_setCaption();
|
_setCaption();
|
||||||
@ -3181,12 +3181,10 @@
|
|||||||
|
|
||||||
if (plyr.media.paused) {
|
if (plyr.media.paused) {
|
||||||
_play();
|
_play();
|
||||||
}
|
} else if (plyr.media.ended) {
|
||||||
else if (plyr.media.ended) {
|
|
||||||
_seek();
|
_seek();
|
||||||
_play();
|
_play();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
_pause();
|
_pause();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -3205,7 +3203,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cancel current network requests
|
// Cancel current network requests
|
||||||
// See https://github.com/Selz/plyr/issues/174
|
// See https://github.com/sampotts/plyr/issues/174
|
||||||
function _cancelRequests() {
|
function _cancelRequests() {
|
||||||
if (!_inArray(config.types.html5, plyr.type)) {
|
if (!_inArray(config.types.html5, plyr.type)) {
|
||||||
return;
|
return;
|
||||||
@ -3220,11 +3218,11 @@
|
|||||||
// Set blank video src attribute
|
// Set blank video src attribute
|
||||||
// This is to prevent a MEDIA_ERR_SRC_NOT_SUPPORTED error
|
// This is to prevent a MEDIA_ERR_SRC_NOT_SUPPORTED error
|
||||||
// Info: http://stackoverflow.com/questions/32231579/how-to-properly-dispose-of-an-html5-video-and-close-socket-or-connection
|
// Info: http://stackoverflow.com/questions/32231579/how-to-properly-dispose-of-an-html5-video-and-close-socket-or-connection
|
||||||
plyr.media.setAttribute('src', 'https://cdn.selz.com/plyr/blank.mp4');
|
plyr.media.setAttribute('src', config.blankUrl);
|
||||||
|
|
||||||
// Load the new empty source
|
// Load the new empty source
|
||||||
// This will cancel existing requests
|
// This will cancel existing requests
|
||||||
// See https://github.com/Selz/plyr/issues/174
|
// See https://github.com/sampotts/plyr/issues/174
|
||||||
plyr.media.load();
|
plyr.media.load();
|
||||||
|
|
||||||
// Debugging
|
// Debugging
|
||||||
@ -3261,7 +3259,7 @@
|
|||||||
plyr.embed.unload().then(cleanUp);
|
plyr.embed.unload().then(cleanUp);
|
||||||
|
|
||||||
// Vimeo does not always return
|
// Vimeo does not always return
|
||||||
window.setTimeout(cleanUp, 200);
|
timers.cleanUp = window.setTimeout(cleanUp, 200);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -3277,6 +3275,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function cleanUp() {
|
function cleanUp() {
|
||||||
|
clearTimeout(timers.cleanUp);
|
||||||
|
|
||||||
// Default to restore original element
|
// Default to restore original element
|
||||||
if (!_is.boolean(restore)) {
|
if (!_is.boolean(restore)) {
|
||||||
restore = true;
|
restore = true;
|
||||||
@ -3298,6 +3298,9 @@
|
|||||||
// Replace the container with the original element provided
|
// Replace the container with the original element provided
|
||||||
plyr.container.parentNode.replaceChild(original, plyr.container);
|
plyr.container.parentNode.replaceChild(original, plyr.container);
|
||||||
|
|
||||||
|
// Allow overflow (set on fullscreen)
|
||||||
|
document.body.style.overflow = '';
|
||||||
|
|
||||||
// Event
|
// Event
|
||||||
_triggerEvent(original, 'destroyed', true);
|
_triggerEvent(original, 'destroyed', true);
|
||||||
}
|
}
|
||||||
@ -3334,8 +3337,7 @@
|
|||||||
// Clean up
|
// Clean up
|
||||||
media.removeAttribute('data-type');
|
media.removeAttribute('data-type');
|
||||||
media.removeAttribute('data-video-id');
|
media.removeAttribute('data-video-id');
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
plyr.type = tagName;
|
plyr.type = tagName;
|
||||||
config.crossorigin = (media.getAttribute('crossorigin') !== null);
|
config.crossorigin = (media.getAttribute('crossorigin') !== null);
|
||||||
config.autoplay = (config.autoplay || (media.getAttribute('autoplay') !== null));
|
config.autoplay = (config.autoplay || (media.getAttribute('autoplay') !== null));
|
||||||
@ -3447,9 +3449,14 @@
|
|||||||
getEmbed: function() { return plyr.embed; },
|
getEmbed: function() { return plyr.embed; },
|
||||||
getMedia: function() { return plyr.media; },
|
getMedia: function() { return plyr.media; },
|
||||||
getType: function() { return plyr.type; },
|
getType: function() { return plyr.type; },
|
||||||
|
getDuration: _getDuration,
|
||||||
|
getCurrentTime: function() { return plyr.media.currentTime; },
|
||||||
|
getVolume: function() { return plyr.media.volume; },
|
||||||
|
isMuted: function() { return plyr.media.muted; },
|
||||||
isReady: function() { return _hasClass(plyr.container, config.classes.ready); },
|
isReady: function() { return _hasClass(plyr.container, config.classes.ready); },
|
||||||
isLoading: function() { return _hasClass(plyr.container, config.classes.loading); },
|
isLoading: function() { return _hasClass(plyr.container, config.classes.loading); },
|
||||||
on: function(event, callback) { _on(plyr.container, event, callback); },
|
isPaused: function() { return plyr.media.paused; },
|
||||||
|
on: function(event, callback) { _on(plyr.container, event, callback); return this; },
|
||||||
play: _play,
|
play: _play,
|
||||||
pause: _pause,
|
pause: _pause,
|
||||||
stop: function() { _pause(); _seek(); },
|
stop: function() { _pause(); _seek(); },
|
||||||
@ -3467,8 +3474,7 @@
|
|||||||
toggleControls: _toggleControls,
|
toggleControls: _toggleControls,
|
||||||
isFullscreen: function() { return plyr.isFullscreen || false; },
|
isFullscreen: function() { return plyr.isFullscreen || false; },
|
||||||
support: function(mimeType) { return _supportMime(plyr, mimeType); },
|
support: function(mimeType) { return _supportMime(plyr, mimeType); },
|
||||||
destroy: _destroy,
|
destroy: _destroy
|
||||||
getCurrentTime: function() { return media.currentTime; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Everything done
|
// Everything done
|
||||||
@ -3524,8 +3530,7 @@
|
|||||||
// Check for CORS support
|
// Check for CORS support
|
||||||
if ('withCredentials' in x) {
|
if ('withCredentials' in x) {
|
||||||
x.open('GET', url, true);
|
x.open('GET', url, true);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3542,31 +3547,48 @@
|
|||||||
var browser = _browserSniff(),
|
var browser = _browserSniff(),
|
||||||
isOldIE = (browser.isIE && browser.version <= 9),
|
isOldIE = (browser.isIE && browser.version <= 9),
|
||||||
isIos = browser.isIos,
|
isIos = browser.isIos,
|
||||||
isIphone = /iPhone|iPod/i.test(navigator.userAgent),
|
isIphone = browser.isIphone,
|
||||||
audio = !!document.createElement('audio').canPlayType,
|
audioSupport = !!document.createElement('audio').canPlayType,
|
||||||
video = !!document.createElement('video').canPlayType,
|
videoSupport = !!document.createElement('video').canPlayType,
|
||||||
basic, full;
|
basic = false,
|
||||||
|
full = false;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'video':
|
case 'video':
|
||||||
basic = video;
|
basic = videoSupport;
|
||||||
full = (basic && (!isOldIE && !isIphone));
|
full = (basic && (!isOldIE && !isIphone));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'audio':
|
case 'audio':
|
||||||
basic = audio;
|
basic = audioSupport;
|
||||||
full = (basic && !isOldIE);
|
full = (basic && !isOldIE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// Vimeo does not seem to be supported on iOS via API
|
||||||
|
// Issue raised https://github.com/vimeo/player.js/issues/87
|
||||||
case 'vimeo':
|
case 'vimeo':
|
||||||
|
basic = true;
|
||||||
|
full = (!isOldIE && !isIos);
|
||||||
|
break;
|
||||||
|
|
||||||
case 'youtube':
|
case 'youtube':
|
||||||
|
basic = true;
|
||||||
|
full = (!isOldIE && !isIos);
|
||||||
|
|
||||||
|
// YouTube seems to work on iOS 10+ on iPad
|
||||||
|
if (isIos && !isIphone && browser.version >= 10) {
|
||||||
|
full = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
case 'soundcloud':
|
case 'soundcloud':
|
||||||
basic = true;
|
basic = true;
|
||||||
full = (!isOldIE && !isIos);
|
full = (!isOldIE && !isIphone);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
basic = (audio && video);
|
basic = (audioSupport && videoSupport);
|
||||||
full = (basic && !isOldIE);
|
full = (basic && !isOldIE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3584,16 +3606,14 @@
|
|||||||
selector = [defaults.selectors.html5, defaults.selectors.embed].join(',');
|
selector = [defaults.selectors.html5, defaults.selectors.embed].join(',');
|
||||||
|
|
||||||
// Select the elements
|
// Select the elements
|
||||||
// Assume elements is a NodeList by default
|
|
||||||
if (_is.string(targets)) {
|
if (_is.string(targets)) {
|
||||||
|
// String selector passed
|
||||||
targets = document.querySelectorAll(targets);
|
targets = document.querySelectorAll(targets);
|
||||||
}
|
} else if (_is.htmlElement(targets)) {
|
||||||
// Single HTMLElement passed
|
// Single HTMLElement passed
|
||||||
else if (_is.htmlElement(targets)) {
|
|
||||||
targets = [targets];
|
targets = [targets];
|
||||||
}
|
} else if (!_is.nodeList(targets) && !_is.array(targets) && !_is.string(targets)) {
|
||||||
// No selector passed, possibly options as first argument
|
// No selector passed, possibly options as first argument
|
||||||
else if (!_is.nodeList(targets) && !_is.array(targets) && !_is.string(targets)) {
|
|
||||||
// If options are the first argument
|
// If options are the first argument
|
||||||
if (_is.undefined(options) && _is.object(targets)) {
|
if (_is.undefined(options) && _is.object(targets)) {
|
||||||
options = targets;
|
options = targets;
|
||||||
@ -3640,9 +3660,8 @@
|
|||||||
for (var x = 0; x < children.length; x++) {
|
for (var x = 0; x < children.length; x++) {
|
||||||
add(target, children[x]);
|
add(target, children[x]);
|
||||||
}
|
}
|
||||||
}
|
} else if (_matches(target, selector)) {
|
||||||
// Wrap target if it's a media element
|
// Target is media element
|
||||||
else if (_matches(target, selector)) {
|
|
||||||
add(target, target);
|
add(target, target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3704,12 +3723,11 @@
|
|||||||
|
|
||||||
// Get all instances within a provided container
|
// Get all instances within a provided container
|
||||||
function get(container) {
|
function get(container) {
|
||||||
// Get selector if string passed
|
|
||||||
if (_is.string(container)) {
|
if (_is.string(container)) {
|
||||||
|
// Get selector if string passed
|
||||||
container = document.querySelector(container);
|
container = document.querySelector(container);
|
||||||
}
|
} else if (_is.undefined(container)) {
|
||||||
// Use body by default to get all on page
|
// Use body by default to get all on page
|
||||||
else if (_is.undefined(container)) {
|
|
||||||
container = document.body;
|
container = document.body;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,16 +173,17 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
background: #000;
|
background: #000;
|
||||||
border-radius: inherit;
|
border-radius: inherit;
|
||||||
|
|
||||||
// Cleaner radius, also forces iframe radius
|
|
||||||
-webkit-mask-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAA5JREFUeNpiYGBgAAgwAAAEAAGbA+oJAAAAAElFTkSuQmCC);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Container for embeds
|
// Container for embeds
|
||||||
.plyr__video-embed {
|
.plyr__video-embed {
|
||||||
padding-bottom: 56.25%; /* 16:9 */
|
padding-bottom: 56.25%; /* 16:9 */
|
||||||
height: 0;
|
height: 0;
|
||||||
|
border-radius: inherit;
|
||||||
|
|
||||||
|
// Require overflow and z-index to force border-radius
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
z-index: 0;
|
||||||
|
|
||||||
iframe {
|
iframe {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@ -244,12 +245,15 @@
|
|||||||
.plyr--captions-active .plyr__captions {
|
.plyr--captions-active .plyr__captions {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
.plyr--fullscreen-active .plyr__captions {
|
|
||||||
font-size: @plyr-font-size-captions-large;
|
|
||||||
}
|
|
||||||
.plyr--hide-controls .plyr__captions {
|
.plyr--hide-controls .plyr__captions {
|
||||||
transform: translateY(-(@plyr-control-spacing * 1.5));
|
transform: translateY(-(@plyr-control-spacing * 1.5));
|
||||||
}
|
}
|
||||||
|
// Large captions in full screen on larger screens
|
||||||
|
@media (min-width: @plyr-bp-screen-lg) {
|
||||||
|
.plyr--fullscreen-active .plyr__captions {
|
||||||
|
font-size: @plyr-font-size-captions-large;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Controls
|
// Controls
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
@ -337,6 +341,7 @@
|
|||||||
left: 0;
|
left: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
|
z-index: 2;
|
||||||
padding: (@plyr-control-spacing * 5) @plyr-control-spacing @plyr-control-spacing;
|
padding: (@plyr-control-spacing * 5) @plyr-control-spacing @plyr-control-spacing;
|
||||||
background: linear-gradient(fade(@plyr-video-controls-bg, 0%), fade(@plyr-video-controls-bg, 50%));
|
background: linear-gradient(fade(@plyr-video-controls-bg, 0%), fade(@plyr-video-controls-bg, 50%));
|
||||||
border-bottom-left-radius: inherit;
|
border-bottom-left-radius: inherit;
|
||||||
@ -736,6 +741,10 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
.plyr__video-embed {
|
||||||
|
// Revert overflow change
|
||||||
|
overflow: visible;
|
||||||
|
}
|
||||||
.plyr__controls {
|
.plyr__controls {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
|
@ -69,3 +69,4 @@
|
|||||||
// Breakpoints
|
// Breakpoints
|
||||||
@plyr-bp-screen-sm: 480px;
|
@plyr-bp-screen-sm: 480px;
|
||||||
@plyr-bp-screen-md: 768px;
|
@plyr-bp-screen-md: 768px;
|
||||||
|
@plyr-bp-screen-lg: 1024px;
|
@ -172,18 +172,18 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
background: #000;
|
background: #000;
|
||||||
border-radius: inherit;
|
border-radius: inherit;
|
||||||
|
|
||||||
// Cleaner radius, also forces iframe radius
|
|
||||||
-webkit-mask-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAA5JREFUeNpiYGBgAAgwAAAEAAGbA+oJAAAAAElFTkSuQmCC);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Container for embeds
|
// Container for embeds
|
||||||
.plyr__video-embed {
|
.plyr__video-embed {
|
||||||
padding-bottom: 56.25%; /* 16:9 */
|
padding-bottom: 56.25%; /* 16:9 */
|
||||||
height: 0;
|
height: 0;
|
||||||
overflow: hidden;
|
|
||||||
border-radius: inherit;
|
border-radius: inherit;
|
||||||
|
|
||||||
|
// Require overflow and z-index to force border-radius
|
||||||
|
overflow: hidden;
|
||||||
|
z-index: 0;
|
||||||
|
|
||||||
iframe {
|
iframe {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
@ -244,12 +244,15 @@
|
|||||||
.plyr--captions-active .plyr__captions {
|
.plyr--captions-active .plyr__captions {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
.plyr--fullscreen-active .plyr__captions {
|
|
||||||
font-size: $plyr-font-size-captions-large;
|
|
||||||
}
|
|
||||||
.plyr--hide-controls .plyr__captions {
|
.plyr--hide-controls .plyr__captions {
|
||||||
transform: translateY(-($plyr-control-spacing * 2));
|
transform: translateY(-($plyr-control-spacing * 2));
|
||||||
}
|
}
|
||||||
|
// Large captions in full screen on larger screens
|
||||||
|
@media (min-width: $plyr-bp-screen-lg) {
|
||||||
|
.plyr--fullscreen-active .plyr__captions {
|
||||||
|
font-size: $plyr-font-size-captions-large;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Controls
|
// Controls
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
@ -735,6 +738,10 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
.plyr__video-embed {
|
||||||
|
// Revert overflow change
|
||||||
|
overflow: visible;
|
||||||
|
}
|
||||||
.plyr__controls {
|
.plyr__controls {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
|
@ -70,3 +70,4 @@ $plyr-range-selected-bg: $plyr-color-main !default;
|
|||||||
// Breakpoints
|
// Breakpoints
|
||||||
$plyr-bp-screen-sm: 480px !default;
|
$plyr-bp-screen-sm: 480px !default;
|
||||||
$plyr-bp-screen-md: 768px !default;
|
$plyr-bp-screen-md: 768px !default;
|
||||||
|
$plyr-bp-screen-lg: 1024px !default;
|
Reference in New Issue
Block a user