Compare commits
32 Commits
Author | SHA1 | Date | |
---|---|---|---|
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 |
12
.github/issue_template.md
vendored
12
.github/issue_template.md
vendored
@ -1,3 +1,7 @@
|
||||
<!---
|
||||
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
|
||||
|
||||
@ -12,7 +16,13 @@
|
||||
- Operating System:
|
||||
- Version:
|
||||
|
||||
Players affected:
|
||||
- [ ] HTML5 Video
|
||||
- [ ] HTML5 Audio
|
||||
- [ ] YouTube
|
||||
- [ ] Vimeo
|
||||
|
||||
### Steps to reproduce
|
||||
-
|
||||
|
||||
### Relevant links
|
||||
### Relevant links
|
||||
|
34
changelog.md
34
changelog.md
@ -1,5 +1,17 @@
|
||||
# Changelog
|
||||
|
||||
## v2.0.12
|
||||
- Ability to set custom `blankUrl` for source changes (https://github.com/Selz/plyr/pull/504)
|
||||
- Ability to set caption button listener (https://github.com/Selz/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)
|
||||
|
||||
@ -17,10 +29,10 @@
|
||||
|
||||
## v2.0.6
|
||||
- Fixed merge issue with `Updated define to work with AMD imports #326` PR
|
||||
- Code formatting
|
||||
- Code formatting
|
||||
|
||||
## v2.0.5
|
||||
- Fix for Vimeo in IE9 & IE10
|
||||
- Fix for Vimeo in IE9 & IE10
|
||||
- Fix for HTML5 elements not firing `ready` event
|
||||
|
||||
## v2.0.4
|
||||
@ -40,8 +52,8 @@ This version contains several potential ***breaking changes***:
|
||||
|
||||
- `setup()` has been reverted to pre v1.8.0 behaviour; meaning it will return the *instance* rather than the *element*. This is because the reference to the instance is no longer added to the original element (see below).
|
||||
- The reference to the `plyr` instance is now added to the media element rather than original container. This is because if a container with multiple children was passed to `setup()` the references to all instances would have been added to the container, creating issues. I would recommend using the return value from `setup()` or the new `get()` method to access the instance.
|
||||
- Players will always be wrapped in their own div now - this makes `setup()` and `destroy()` cleaner. This *may* break any custom styling based on DOM position.
|
||||
- Players no longer seek to 0 on 'ended' - this is to fix a bug with Microsoft Edge as it triggers 'ended' on media change for whatever reason. They'll never change ;-)
|
||||
- Players will always be wrapped in their own div now - this makes `setup()` and `destroy()` cleaner. This *may* break any custom styling based on DOM position.
|
||||
- Players no longer seek to 0 on 'ended' - this is to fix a bug with Microsoft Edge as it triggers 'ended' on media change for whatever reason. They'll never change ;-)
|
||||
|
||||
And some other changes and bug fixes:
|
||||
|
||||
@ -71,7 +83,7 @@ And some other changes and bug fixes:
|
||||
|
||||
## v1.8.11
|
||||
- Fix for keyboard navigation on Vimeo (Fixes #317)
|
||||
- Fix for bug introduced in v1.8.9 related to additional controls
|
||||
- Fix for bug introduced in v1.8.9 related to additional controls
|
||||
- Vimeo API upgrade
|
||||
- Fix for YouTube bug introduced in v1.8.9
|
||||
- Added support for passing array to .setup() (Fixes #319)
|
||||
@ -111,20 +123,20 @@ And some other changes and bug fixes:
|
||||
- Improvements for controls hiding and showing on touch devices
|
||||
|
||||
## v1.8.2
|
||||
- Fixed event bubbling
|
||||
- Fixed event bubbling
|
||||
|
||||
## v1.8.1
|
||||
- Fixed inaccurate log message
|
||||
|
||||
# v1.8.0
|
||||
- ***(Important)*** `setup()` now returns the element Plyr was setup on rather than the `plyr` object. This means `var player = plyr.setup()[0];` would now be `var player = plyr.setup()[0].plyr;`. This improves support for React and other virtual dom frameworks as mentioned in #254
|
||||
- Fixed using a relative URL for `iconUrl` in IE (fixes #269)
|
||||
- Fixed using a relative URL for `iconUrl` in IE (fixes #269)
|
||||
|
||||
# v1.7.0
|
||||
- SASS cleanup (fixes #265)
|
||||
- Docs tidy up to help quick start (fixes #253)
|
||||
- Fix for issues with data attribute options passing (fixes #257)
|
||||
- ***(Important)*** Removed the requirement for a wrapper div to setup Plyr and removed the dependency on the `plyr` classname as a JS hook. By default it will now look for `<video>`, `<audio>` and `[data-type]` elements. If you are just calling `setup()` with a `<div class="plyr">` you may want to give it a good test after upgrading. You can probably remove the wrapper div. The reason behind this is to make setup easier for newcomers and prevent the styling being used on unsupported players (because the plyr classname was used as a CSS and JS hook - which isn't ideal)
|
||||
- ***(Important)*** Removed the requirement for a wrapper div to setup Plyr and removed the dependency on the `plyr` classname as a JS hook. By default it will now look for `<video>`, `<audio>` and `[data-type]` elements. If you are just calling `setup()` with a `<div class="plyr">` you may want to give it a good test after upgrading. You can probably remove the wrapper div. The reason behind this is to make setup easier for newcomers and prevent the styling being used on unsupported players (because the plyr classname was used as a CSS and JS hook - which isn't ideal)
|
||||
- Renamed the 'docs' folder to `demo` to avoid confusion - the readme is the docs after all
|
||||
|
||||
## v1.6.20
|
||||
@ -154,7 +166,7 @@ And some other changes and bug fixes:
|
||||
- Decreased sensitivity and inverted scroll on volume slider (scroll up to increase, down to decrease)
|
||||
|
||||
## v1.6.12
|
||||
- Fix for undefined buffer error
|
||||
- Fix for undefined buffer error
|
||||
- Add scroll listener on volume slider (PR #227 bty @igoradamenko)
|
||||
|
||||
## v1.6.11
|
||||
@ -196,13 +208,13 @@ And some other changes and bug fixes:
|
||||
- Other minor bug fixes
|
||||
|
||||
## v1.6.1
|
||||
- Tooltip changes for accessibility
|
||||
- Tooltip changes for accessibility
|
||||
|
||||
## v1.6.0
|
||||
- New, cleaner, UI:
|
||||
- Controls are now overlaid, maintaining the video's ratio and making sizing easier
|
||||
- A large play button can now be overlaid over videos
|
||||
- Default number of control buttons reduced
|
||||
- Default number of control buttons reduced
|
||||
- New play, pause, rewind and fast forward icons
|
||||
- Flexbox all the things!
|
||||
- Tidied up the LESS (and SCSS) as part of the above, variables and mixins in seprate files amking customization and upgrades easier
|
||||
|
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;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:"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:"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"));
|
@ -51,7 +51,7 @@
|
||||
</ul>
|
||||
</nav>
|
||||
<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 -->
|
||||
<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">
|
||||
@ -66,8 +66,8 @@
|
||||
<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--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--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--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>
|
||||
</ul>
|
||||
</section>
|
||||
</main>
|
||||
|
@ -9,7 +9,7 @@
|
||||
// General functions
|
||||
;(function() {
|
||||
//document.body.addEventListener('ready', function(event) { console.log(event); });
|
||||
|
||||
|
||||
// Setup the player
|
||||
var instances = plyr.setup({
|
||||
debug: true,
|
||||
@ -94,7 +94,7 @@
|
||||
// Set a new source
|
||||
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
|
||||
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;
|
||||
}
|
||||
|
||||
|
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
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "plyr",
|
||||
"version": "2.0.9",
|
||||
"version": "2.0.12",
|
||||
"description": "A simple, accessible and customizable HTML5, YouTube and Vimeo media player",
|
||||
"homepage": "http://plyr.io",
|
||||
"main": "src/js/plyr.js",
|
||||
|
66
readme.md
66
readme.md
@ -1,6 +1,8 @@
|
||||
# Plyr
|
||||
A simple, accessible and customizable HTML5, YouTube and Vimeo media player.
|
||||
|
||||
[Donate to support Plyr](#donate)
|
||||
|
||||
[Checkout the demo](https://plyr.io)
|
||||
|
||||
[](https://plyr.io)
|
||||
@ -30,13 +32,23 @@ Oh and yes, it works with Bootstrap.
|
||||
## Changelog
|
||||
Check out the [changelog](changelog.md) to see what's new with Plyr.
|
||||
|
||||
## Planned Development
|
||||
- Playback speed
|
||||
- Quality selection
|
||||
## Features currently being developed
|
||||
- Playback speed selection
|
||||
- Quality selection
|
||||
- Caption language selection
|
||||
- AirPlay
|
||||
- Picture in Picture (MacOS Sierra + Safari)
|
||||
|
||||
[more info](https://github.com/Selz/plyr/issues?q=is%3Aissue+is%3Aopen+label%3A%22In+Development%22)
|
||||
|
||||
## Planned features
|
||||
- Playlists
|
||||
- Multiple language captions (with selection)
|
||||
- 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/Selz/plyr/issues)
|
||||
...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.
|
||||
|
||||
@ -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>
|
||||
```
|
||||
|
||||
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
|
||||
```html
|
||||
<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
|
||||
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>
|
||||
```
|
||||
|
||||
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
|
||||
<script src="https://cdn.plyr.io/2.0.9/plyr.js"></script>
|
||||
<script src="https://cdn.plyr.io/2.0.12/plyr.js"></script>
|
||||
```
|
||||
|
||||
### CSS
|
||||
@ -132,14 +147,14 @@ Include the `plyr.css` stylsheet into your `<head>`
|
||||
<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
|
||||
<link rel="stylesheet" href="https://cdn.plyr.io/2.0.9/plyr.css">
|
||||
<link rel="stylesheet" href="https://cdn.plyr.io/2.0.12/plyr.css">
|
||||
```
|
||||
|
||||
### 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.9/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.12/plyr.svg`.
|
||||
|
||||
## 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>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>
|
||||
<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/Selz/plyr/issues/174">issue #174</a> for more info.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>debug</code></td>
|
||||
<td>Boolean</td>
|
||||
@ -676,6 +697,8 @@ player.source({
|
||||
});
|
||||
```
|
||||
|
||||
Note: `src` can be the video ID or URL
|
||||
|
||||
Vimeo example
|
||||
|
||||
```javascript
|
||||
@ -689,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%">
|
||||
<thead>
|
||||
@ -713,7 +738,7 @@ Some more details on the object parameters
|
||||
<tr>
|
||||
<td><code>sources</code></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>
|
||||
<td><code>poster</code></td>
|
||||
@ -776,7 +801,7 @@ These events also bubble up the DOM. The event target will be the container elem
|
||||
<tr>
|
||||
<td><code>ended</code></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>
|
||||
<td><code>error</code></td>
|
||||
@ -820,12 +845,12 @@ These events also bubble up the DOM. The event target will be the container elem
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>seeked</code></td>
|
||||
<td>✔</td>
|
||||
<td></td>
|
||||
<td>Sent when a seek operation completes.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>seeking</code></td>
|
||||
<td>✔</td>
|
||||
<td></td>
|
||||
<td>Sent when a seek operation begins.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -996,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+)
|
||||
|
||||
³ 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:
|
||||
|
||||
@ -1016,6 +1041,10 @@ If you find anything weird with Plyr, please let us know using the GitHub issues
|
||||
## 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)
|
||||
|
||||
## 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
|
||||
- [ProductHunt](https://www.producthunt.com/tech/plyr)
|
||||
- [The Changelog](http://thechangelog.com/plyr-simple-html5-media-player-custom-controls-webvtt-captions/)
|
||||
@ -1050,5 +1079,10 @@ Also these links helped created Plyr:
|
||||
- [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/)
|
||||
|
||||
## Thanks
|
||||
[](https://www.fastly.com/)
|
||||
|
||||
Thanks to [Fastly](https://www.fastly.com/) for providing the CDN services.
|
||||
|
||||
## Copyright and License
|
||||
[The MIT license](license.md).
|
||||
|
194
src/js/plyr.js
194
src/js/plyr.js
@ -1,6 +1,6 @@
|
||||
// ==========================================================================
|
||||
// Plyr
|
||||
// plyr.js v2.0.9
|
||||
// plyr.js v2.0.12
|
||||
// https://github.com/selz/plyr
|
||||
// License: The MIT License (MIT)
|
||||
// ==========================================================================
|
||||
@ -25,7 +25,7 @@
|
||||
'use strict';
|
||||
|
||||
// Globals
|
||||
var fullscreen,
|
||||
var fullscreen,
|
||||
scroll = { x: 0, y: 0 },
|
||||
|
||||
// Default config
|
||||
@ -36,14 +36,15 @@
|
||||
loop: false,
|
||||
seekTime: 10,
|
||||
volume: 10,
|
||||
volumeMin: 0,
|
||||
volumeMax: 10,
|
||||
volumeMin: 0,
|
||||
volumeMax: 10,
|
||||
volumeStep: 1,
|
||||
duration: null,
|
||||
displayDuration: true,
|
||||
loadSprite: true,
|
||||
iconPrefix: 'plyr',
|
||||
iconUrl: 'https://cdn.plyr.io/2.0.9/plyr.svg',
|
||||
iconUrl: 'https://cdn.plyr.io/2.0.12/plyr.svg',
|
||||
blankUrl: 'https://cdn.selz.com/plyr/blank.mp4',
|
||||
clickToPlay: true,
|
||||
hideControls: true,
|
||||
showPosterOnEnd: false,
|
||||
@ -175,7 +176,7 @@
|
||||
fullscreen: null
|
||||
},
|
||||
// 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
|
||||
logPrefix: '[Plyr]'
|
||||
};
|
||||
@ -257,6 +258,7 @@
|
||||
isChrome: isChrome,
|
||||
isSafari: isSafari,
|
||||
isIos: /(iPad|iPhone|iPod)/g.test(navigator.platform),
|
||||
isIphone: /(iPhone|iPod)/g.test(navigator.userAgent),
|
||||
isTouch: 'ontouchstart' in document.documentElement
|
||||
};
|
||||
}
|
||||
@ -493,9 +495,9 @@
|
||||
}
|
||||
|
||||
// Create and dispatch the event
|
||||
var event = new CustomEvent(type, {
|
||||
var event = new CustomEvent(type, {
|
||||
bubbles: bubbles,
|
||||
detail: properties
|
||||
detail: properties
|
||||
});
|
||||
|
||||
// Dispatch the event
|
||||
@ -568,7 +570,7 @@
|
||||
// Check variable types
|
||||
var _is = {
|
||||
object: function(input) {
|
||||
return input !== null && typeof(input) === 'object';
|
||||
return input !== null && typeof(input) === 'object';
|
||||
},
|
||||
array: function(input) {
|
||||
return input !== null && (typeof(input) === 'object' && input.constructor === Array);
|
||||
@ -596,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
|
||||
function _fullscreen() {
|
||||
var fullscreen = {
|
||||
@ -701,7 +715,7 @@
|
||||
timers = {},
|
||||
api;
|
||||
|
||||
// Set media
|
||||
// Set media
|
||||
plyr.media = media;
|
||||
var original = media.cloneNode(true);
|
||||
|
||||
@ -720,7 +734,7 @@
|
||||
if (_is.string(config.logPrefix) && config.logPrefix.length) {
|
||||
args.unshift(config.logPrefix);
|
||||
}
|
||||
|
||||
|
||||
console[type].apply(console, args);
|
||||
}
|
||||
}
|
||||
@ -1025,7 +1039,7 @@
|
||||
var captions = [],
|
||||
caption,
|
||||
req = xhr.responseText;
|
||||
|
||||
|
||||
//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';
|
||||
@ -1036,7 +1050,7 @@
|
||||
lineSeparator = '\n';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
captions = req.split(lineSeparator+lineSeparator);
|
||||
|
||||
for (var r = 0; r < captions.length; r++) {
|
||||
@ -1477,7 +1491,7 @@
|
||||
_toggleClass(plyr.container, config.classes.stopped, config.autoplay);
|
||||
|
||||
// Add iOS class
|
||||
_toggleClass(plyr.ontainer, config.classes.isIos, plyr.browser.isIos);
|
||||
_toggleClass(plyr.container, config.classes.isIos, plyr.browser.isIos);
|
||||
|
||||
// Add touch class
|
||||
_toggleClass(plyr.container, config.classes.isTouch, plyr.browser.isTouch);
|
||||
@ -1505,9 +1519,23 @@
|
||||
// Setup YouTube/Vimeo
|
||||
function _setupEmbed() {
|
||||
var container = document.createElement('div'),
|
||||
mediaId = plyr.embedId,
|
||||
mediaId,
|
||||
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
|
||||
var containers = _getElements('[id^="' + plyr.type + '-"]');
|
||||
for (var i = containers.length - 1; i >= 0; i--) {
|
||||
@ -1724,6 +1752,12 @@
|
||||
|
||||
case 1:
|
||||
plyr.media.paused = false;
|
||||
|
||||
// If we were seeking, fire seeked event
|
||||
if (plyr.media.seeking) {
|
||||
_triggerEvent(plyr.media, 'seeked');
|
||||
}
|
||||
|
||||
plyr.media.seeking = false;
|
||||
_triggerEvent(plyr.media, 'play');
|
||||
_triggerEvent(plyr.media, 'playing');
|
||||
@ -1787,7 +1821,7 @@
|
||||
plyr.embed.stop();
|
||||
plyr.media.paused = true;
|
||||
};
|
||||
|
||||
|
||||
plyr.media.paused = true;
|
||||
plyr.media.currentTime = 0;
|
||||
|
||||
@ -1803,7 +1837,7 @@
|
||||
|
||||
plyr.embed.getDuration().then(function(value) {
|
||||
plyr.media.duration = value;
|
||||
|
||||
|
||||
// Trigger timeupdate
|
||||
_triggerEvent(plyr.media, 'durationchange');
|
||||
});
|
||||
@ -1848,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.media.paused = true;
|
||||
_triggerEvent(plyr.media, 'ended');
|
||||
@ -1860,7 +1900,7 @@
|
||||
plyr.embed = window.SC.Widget(this);
|
||||
|
||||
// Setup on ready
|
||||
plyr.embed.bind(window.SC.Widget.Events.READY, function() {
|
||||
plyr.embed.bind(window.SC.Widget.Events.READY, function() {
|
||||
// Create a faux HTML5 API using the Soundcloud API
|
||||
plyr.media.play = function() {
|
||||
plyr.embed.play();
|
||||
@ -1997,7 +2037,7 @@
|
||||
targetTime = duration;
|
||||
}
|
||||
|
||||
// Update seek range and progress
|
||||
// Update seek range and progress
|
||||
_updateSeekDisplay(targetTime);
|
||||
|
||||
// Set the current time
|
||||
@ -2009,7 +2049,6 @@
|
||||
|
||||
// Embeds
|
||||
if (_inArray(config.types.embed, plyr.type)) {
|
||||
// YouTube
|
||||
switch(plyr.type) {
|
||||
case 'youtube':
|
||||
plyr.embed.seekTo(targetTime);
|
||||
@ -2029,11 +2068,14 @@
|
||||
_pause();
|
||||
}
|
||||
|
||||
// Trigger timeupdate for embeds
|
||||
// Trigger timeupdate
|
||||
_triggerEvent(plyr.media, 'timeupdate');
|
||||
|
||||
// Set seeking flag
|
||||
plyr.media.seeking = true;
|
||||
|
||||
// Trigger seeking
|
||||
_triggerEvent(plyr.media, 'seeking');
|
||||
}
|
||||
|
||||
// Logging
|
||||
@ -2086,7 +2128,7 @@
|
||||
function _toggleFullscreen(event) {
|
||||
// Check for native support
|
||||
var nativeSupport = fullscreen.supportsFullScreen;
|
||||
|
||||
|
||||
if (nativeSupport) {
|
||||
// If it's a fullscreen change event, update the UI
|
||||
if (event && event.type === fullscreen.fullScreenEventName) {
|
||||
@ -2384,7 +2426,7 @@
|
||||
if (!plyr.supported.full) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Default to 0
|
||||
if (_is.undefined(value)) {
|
||||
value = 0;
|
||||
@ -2476,7 +2518,7 @@
|
||||
_updateProgress(event);
|
||||
}
|
||||
|
||||
// Update seek range and progress
|
||||
// Update seek range and progress
|
||||
function _updateSeekDisplay(time) {
|
||||
// Default to 0
|
||||
if (!_is.number(time)) {
|
||||
@ -2486,7 +2528,7 @@
|
||||
var duration = _getDuration(),
|
||||
value = _getPercentage(time, duration);
|
||||
|
||||
// Update progress
|
||||
// Update progress
|
||||
if (plyr.progress && plyr.progress.played) {
|
||||
plyr.progress.played.value = value;
|
||||
}
|
||||
@ -2595,15 +2637,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
// If toggle is false or if we're playing (regardless of toggle),
|
||||
// then set the timer to hide the controls
|
||||
// If toggle is false or if we're playing (regardless of toggle),
|
||||
// then set the timer to hide the controls
|
||||
if (!show || !plyr.media.paused) {
|
||||
timers.hover = window.setTimeout(function() {
|
||||
// If the mouse is over the controls (and not entering fullscreen), bail
|
||||
if ((plyr.controls.pressed || plyr.controls.hover) && !isEnterFullscreen) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
_toggleClass(plyr.container, config.classes.hideControls, true);
|
||||
}, delay);
|
||||
}
|
||||
@ -2680,7 +2722,7 @@
|
||||
_remove(plyr.videoContainer);
|
||||
}
|
||||
|
||||
// Reset class name
|
||||
// Reset class name
|
||||
if (plyr.container) {
|
||||
plyr.container.removeAttribute('class');
|
||||
}
|
||||
@ -2875,7 +2917,7 @@
|
||||
count = get().length;
|
||||
|
||||
// Only handle global key press if there's only one player
|
||||
// and the key is in the allowed keys
|
||||
// and the key is in the allowed keys
|
||||
// and if the focused element is not editable (e.g. text input)
|
||||
// and any that accept key input http://webaim.org/techniques/keyboard/
|
||||
if (count === 1 && _inArray(allowed, code) && (!_is.htmlElement(focused) || !_matches(focused, config.selectors.editable))) {
|
||||
@ -2909,7 +2951,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// Divide the max duration into 10th's and times by the number value
|
||||
// Divide the max duration into 10th's and times by the number value
|
||||
_seek((duration / 10) * (code - 48));
|
||||
}
|
||||
|
||||
@ -2927,18 +2969,18 @@
|
||||
|
||||
switch(code) {
|
||||
// 0-9
|
||||
case 48:
|
||||
case 49:
|
||||
case 50:
|
||||
case 51:
|
||||
case 52:
|
||||
case 53:
|
||||
case 54:
|
||||
case 55:
|
||||
case 48:
|
||||
case 49:
|
||||
case 50:
|
||||
case 51:
|
||||
case 52:
|
||||
case 53:
|
||||
case 54:
|
||||
case 55:
|
||||
case 56:
|
||||
case 57: if (!held) { seekByKey(); } break;
|
||||
// Space and K key
|
||||
case 32:
|
||||
case 32:
|
||||
case 75: if (!held) { _togglePlay(); } break;
|
||||
// Arrow up
|
||||
case 38: _increaseVolume(); break;
|
||||
@ -2956,7 +2998,7 @@
|
||||
case 67: if (!held) { _toggleCaptions(); } break;
|
||||
}
|
||||
|
||||
// Escape is handle natively when in full screen
|
||||
// Escape is handle natively when in full screen
|
||||
// So we only need to worry about non native
|
||||
if (!fullscreen.supportsFullScreen && plyr.isFullscreen && code === 27) {
|
||||
_toggleFullscreen();
|
||||
@ -3024,7 +3066,7 @@
|
||||
}
|
||||
|
||||
// Captions
|
||||
_on(plyr.buttons.captions, 'click', _toggleCaptions);
|
||||
_proxyListener(plyr.buttons.captions, 'click', config.listeners.captions, _toggleCaptions);
|
||||
|
||||
// Seek tooltip
|
||||
_on(plyr.progress.container, 'mouseenter mouseleave mousemove', _updateSeekTooltip);
|
||||
@ -3035,12 +3077,12 @@
|
||||
_on(plyr.container, 'mouseenter mouseleave mousemove touchstart touchend touchcancel touchmove enterfullscreen', _toggleControls);
|
||||
|
||||
// Watch for cursor over controls so they don't hide when trying to interact
|
||||
_on(plyr.controls, 'mouseenter mouseleave', function(event) {
|
||||
_on(plyr.controls, 'mouseenter mouseleave', function(event) {
|
||||
plyr.controls.hover = event.type === 'mouseenter';
|
||||
});
|
||||
|
||||
// Watch for cursor over controls so they don't hide when trying to interact
|
||||
_on(plyr.controls, 'mousedown mouseup touchstart touchend touchcancel', function(event) {
|
||||
_on(plyr.controls, 'mousedown mouseup touchstart touchend touchcancel', function(event) {
|
||||
plyr.controls.pressed = _inArray(['mousedown', 'touchstart'], event.type);
|
||||
});
|
||||
|
||||
@ -3096,7 +3138,7 @@
|
||||
if (plyr.type === 'video') {
|
||||
_setCaption();
|
||||
}
|
||||
|
||||
|
||||
// Restart
|
||||
_seek();
|
||||
|
||||
@ -3176,7 +3218,7 @@
|
||||
// Set blank video src attribute
|
||||
// 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
|
||||
plyr.media.setAttribute('src', 'https://cdn.selz.com/plyr/blank.mp4');
|
||||
plyr.media.setAttribute('src', config.blankUrl);
|
||||
|
||||
// Load the new empty source
|
||||
// This will cancel existing requests
|
||||
@ -3198,7 +3240,7 @@
|
||||
|
||||
// Type specific stuff
|
||||
switch (plyr.type) {
|
||||
case 'youtube':
|
||||
case 'youtube':
|
||||
// Clear timers
|
||||
window.clearInterval(timers.buffering);
|
||||
window.clearInterval(timers.playing);
|
||||
@ -3208,16 +3250,16 @@
|
||||
|
||||
// Clean up
|
||||
cleanUp();
|
||||
|
||||
|
||||
break;
|
||||
|
||||
case 'vimeo':
|
||||
// Destroy Vimeo API
|
||||
// Destroy Vimeo API
|
||||
// then clean up (wait, to prevent postmessage errors)
|
||||
plyr.embed.unload().then(cleanUp);
|
||||
|
||||
// Vimeo does not always return
|
||||
window.setTimeout(cleanUp, 200);
|
||||
timers.cleanUp = window.setTimeout(cleanUp, 200);
|
||||
|
||||
break;
|
||||
|
||||
@ -3233,6 +3275,8 @@
|
||||
}
|
||||
|
||||
function cleanUp() {
|
||||
clearTimeout(timers.cleanUp);
|
||||
|
||||
// Default to restore original element
|
||||
if (!_is.boolean(restore)) {
|
||||
restore = true;
|
||||
@ -3254,6 +3298,9 @@
|
||||
// Replace the container with the original element provided
|
||||
plyr.container.parentNode.replaceChild(original, plyr.container);
|
||||
|
||||
// Allow overflow (set on fullscreen)
|
||||
document.body.style.overflow = '';
|
||||
|
||||
// Event
|
||||
_triggerEvent(original, 'destroyed', true);
|
||||
}
|
||||
@ -3408,7 +3455,7 @@
|
||||
isMuted: function() { return plyr.media.muted; },
|
||||
isReady: function() { return _hasClass(plyr.container, config.classes.ready); },
|
||||
isLoading: function() { return _hasClass(plyr.container, config.classes.loading); },
|
||||
isPaused: function() { return plyr.media.paused; },
|
||||
isPaused: function() { return plyr.media.paused; },
|
||||
on: function(event, callback) { _on(plyr.container, event, callback); return this; },
|
||||
play: _play,
|
||||
pause: _pause,
|
||||
@ -3433,7 +3480,7 @@
|
||||
// Everything done
|
||||
function _ready() {
|
||||
// Ready event at end of execution stack
|
||||
window.setTimeout(function() {
|
||||
window.setTimeout(function() {
|
||||
_triggerEvent(plyr.media, 'ready');
|
||||
}, 0);
|
||||
|
||||
@ -3500,31 +3547,48 @@
|
||||
var browser = _browserSniff(),
|
||||
isOldIE = (browser.isIE && browser.version <= 9),
|
||||
isIos = browser.isIos,
|
||||
isIphone = /iPhone|iPod/i.test(navigator.userAgent),
|
||||
audio = !!document.createElement('audio').canPlayType,
|
||||
video = !!document.createElement('video').canPlayType,
|
||||
basic, full;
|
||||
isIphone = browser.isIphone,
|
||||
audioSupport = !!document.createElement('audio').canPlayType,
|
||||
videoSupport = !!document.createElement('video').canPlayType,
|
||||
basic = false,
|
||||
full = false;
|
||||
|
||||
switch (type) {
|
||||
case 'video':
|
||||
basic = video;
|
||||
basic = videoSupport;
|
||||
full = (basic && (!isOldIE && !isIphone));
|
||||
break;
|
||||
|
||||
case 'audio':
|
||||
basic = audio;
|
||||
basic = audioSupport;
|
||||
full = (basic && !isOldIE);
|
||||
break;
|
||||
|
||||
// Vimeo does not seem to be supported on iOS via API
|
||||
// Issue raised https://github.com/vimeo/player.js/issues/87
|
||||
case 'vimeo':
|
||||
basic = true;
|
||||
full = (!isOldIE && !isIos);
|
||||
break;
|
||||
|
||||
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':
|
||||
basic = true;
|
||||
full = (!isOldIE && !isIos);
|
||||
full = (!isOldIE && !isIphone);
|
||||
break;
|
||||
|
||||
default:
|
||||
basic = (audio && video);
|
||||
basic = (audioSupport && videoSupport);
|
||||
full = (basic && !isOldIE);
|
||||
}
|
||||
|
||||
@ -3639,15 +3703,15 @@
|
||||
// Listen for events if debugging
|
||||
if (config.debug) {
|
||||
var events = config.events.concat(['setup', 'statechange', 'enterfullscreen', 'exitfullscreen', 'captionsenabled', 'captionsdisabled']);
|
||||
|
||||
_on(instance.getContainer(), events.join(' '), function(event) {
|
||||
|
||||
_on(instance.getContainer(), events.join(' '), function(event) {
|
||||
console.log([config.logPrefix, 'event:', event.type].join(' '), event.detail.plyr);
|
||||
});
|
||||
}
|
||||
|
||||
// Callback
|
||||
_event(instance.getContainer(), 'setup', true, {
|
||||
plyr: instance
|
||||
_event(instance.getContainer(), 'setup', true, {
|
||||
plyr: instance
|
||||
});
|
||||
|
||||
// Add to return array even if it's already setup
|
||||
@ -3678,7 +3742,7 @@
|
||||
}
|
||||
});
|
||||
|
||||
return instances;
|
||||
return instances;
|
||||
}
|
||||
|
||||
return [];
|
||||
|
@ -61,14 +61,14 @@
|
||||
height: (@plyr-range-thumb-height * @plyr-range-thumb-active-scale);
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
padding: 0;
|
||||
vertical-align: middle;
|
||||
|
||||
|
||||
appearance: none;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
background: transparent;
|
||||
|
||||
|
||||
// WebKit
|
||||
&::-webkit-slider-runnable-track {
|
||||
.plyr-range-track();
|
||||
@ -86,7 +86,7 @@
|
||||
&::-moz-range-thumb {
|
||||
.plyr-range-thumb();
|
||||
}
|
||||
|
||||
|
||||
// Microsoft
|
||||
&::-ms-track {
|
||||
height: @plyr-range-track-height;
|
||||
@ -104,7 +104,7 @@
|
||||
&::-ms-thumb {
|
||||
.plyr-range-thumb();
|
||||
// For some reason, Edge uses the -webkit margin above
|
||||
margin-top: 0;
|
||||
margin-top: 0;
|
||||
}
|
||||
&::-ms-tooltip {
|
||||
display: none;
|
||||
@ -116,11 +116,11 @@
|
||||
}
|
||||
&::-moz-focus-outer {
|
||||
border: 0;
|
||||
}
|
||||
}
|
||||
&.tab-focus:focus {
|
||||
outline-offset: 3px;
|
||||
}
|
||||
|
||||
|
||||
// Pressed styles
|
||||
&:active {
|
||||
&::-webkit-slider-thumb {
|
||||
@ -179,9 +179,10 @@
|
||||
.plyr__video-embed {
|
||||
padding-bottom: 56.25%; /* 16:9 */
|
||||
height: 0;
|
||||
overflow: hidden;
|
||||
border-radius: inherit;
|
||||
|
||||
// Require z-index to force border-radius
|
||||
// Require overflow and z-index to force border-radius
|
||||
overflow: hidden;
|
||||
z-index: 0;
|
||||
|
||||
iframe {
|
||||
@ -192,7 +193,6 @@
|
||||
height: 100%;
|
||||
border: 0;
|
||||
user-select: none;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
// Vimeo hack
|
||||
@ -265,7 +265,7 @@
|
||||
// Playback controls
|
||||
.plyr__controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
align-items: center;
|
||||
line-height: 1;
|
||||
text-align: center;
|
||||
|
||||
@ -329,7 +329,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
// Hide controls
|
||||
// Hide controls
|
||||
.plyr--hide-controls .plyr__controls {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
@ -341,6 +341,7 @@
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 2;
|
||||
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%));
|
||||
border-bottom-left-radius: inherit;
|
||||
@ -476,7 +477,7 @@
|
||||
height: 0;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
|
||||
|
||||
// The background triangle
|
||||
bottom: -@plyr-tooltip-arrow-size;
|
||||
border-right: @plyr-tooltip-arrow-size solid transparent;
|
||||
@ -624,16 +625,16 @@
|
||||
}
|
||||
&::-moz-progress-bar {
|
||||
transition: width .2s ease;
|
||||
}
|
||||
}
|
||||
&::-ms-fill {
|
||||
transition: width .2s ease;
|
||||
}
|
||||
}
|
||||
}
|
||||
.plyr--video .plyr__progress--buffer,
|
||||
.plyr--video .plyr__volume--display {
|
||||
background: @plyr-video-range-track-bg;
|
||||
}
|
||||
.plyr--video .plyr__progress--buffer {
|
||||
.plyr--video .plyr__progress--buffer {
|
||||
color: @plyr-video-progress-buffered-bg;
|
||||
}
|
||||
.plyr--audio .plyr__progress--buffer,
|
||||
@ -740,6 +741,10 @@
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
.plyr__video-embed {
|
||||
// Revert overflow change
|
||||
overflow: visible;
|
||||
}
|
||||
.plyr__controls {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
|
@ -61,14 +61,14 @@
|
||||
height: ($plyr-range-thumb-height * $plyr-range-thumb-active-scale);
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
padding: 0;
|
||||
vertical-align: middle;
|
||||
|
||||
|
||||
appearance: none;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
background: transparent;
|
||||
|
||||
|
||||
// WebKit
|
||||
&::-webkit-slider-runnable-track {
|
||||
@include plyr-range-track();
|
||||
@ -86,7 +86,7 @@
|
||||
&::-moz-range-thumb {
|
||||
@include plyr-range-thumb();
|
||||
}
|
||||
|
||||
|
||||
// Microsoft
|
||||
&::-ms-track {
|
||||
height: $plyr-range-track-height;
|
||||
@ -104,7 +104,7 @@
|
||||
&::-ms-thumb {
|
||||
@include plyr-range-thumb();
|
||||
// For some reason, Edge uses the -webkit margin above
|
||||
margin-top: 0;
|
||||
margin-top: 0;
|
||||
}
|
||||
&::-ms-tooltip {
|
||||
display: none;
|
||||
@ -116,11 +116,11 @@
|
||||
}
|
||||
&::-moz-focus-outer {
|
||||
border: 0;
|
||||
}
|
||||
}
|
||||
&.tab-focus:focus {
|
||||
outline-offset: 3px;
|
||||
}
|
||||
|
||||
|
||||
// Pressed styles
|
||||
&:active {
|
||||
&::-webkit-slider-thumb {
|
||||
@ -178,10 +178,10 @@
|
||||
.plyr__video-embed {
|
||||
padding-bottom: 56.25%; /* 16:9 */
|
||||
height: 0;
|
||||
overflow: hidden;
|
||||
border-radius: inherit;
|
||||
|
||||
// Require z-index to force border-radius
|
||||
// Require overflow and z-index to force border-radius
|
||||
overflow: hidden;
|
||||
z-index: 0;
|
||||
|
||||
iframe {
|
||||
@ -264,7 +264,7 @@
|
||||
// Playback controls
|
||||
.plyr__controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
align-items: center;
|
||||
line-height: 1;
|
||||
text-align: center;
|
||||
|
||||
@ -328,7 +328,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
// Hide controls
|
||||
// Hide controls
|
||||
.plyr--hide-controls .plyr__controls {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
@ -475,7 +475,7 @@
|
||||
height: 0;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
|
||||
|
||||
// The background triangle
|
||||
bottom: -$plyr-tooltip-arrow-size;
|
||||
border-right: $plyr-tooltip-arrow-size solid transparent;
|
||||
@ -622,16 +622,16 @@
|
||||
}
|
||||
&::-moz-progress-bar {
|
||||
transition: width .2s ease;
|
||||
}
|
||||
}
|
||||
&::-ms-fill {
|
||||
transition: width .2s ease;
|
||||
}
|
||||
}
|
||||
}
|
||||
.plyr--video .plyr__progress--buffer,
|
||||
.plyr--video .plyr__volume--display {
|
||||
background: $plyr-video-range-track-bg;
|
||||
}
|
||||
.plyr--video .plyr__progress--buffer {
|
||||
.plyr--video .plyr__progress--buffer {
|
||||
color: $plyr-video-progress-buffered-bg;
|
||||
}
|
||||
.plyr--audio .plyr__progress--buffer,
|
||||
@ -738,6 +738,10 @@
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
.plyr__video-embed {
|
||||
// Revert overflow change
|
||||
overflow: visible;
|
||||
}
|
||||
.plyr__controls {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
|
Reference in New Issue
Block a user