Compare commits
96 Commits
Author | SHA1 | Date | |
---|---|---|---|
b3759e966d | |||
34172b9aee | |||
a21ffe983c | |||
9fb79f29fd | |||
032d73408f | |||
3fe0c7c84b | |||
6828bc00f8 | |||
e95c81cc5b | |||
c0eee58732 | |||
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 | |||
1ced6b4d67 | |||
6694c1e6cf | |||
19ca906e50 | |||
12e94775d6 | |||
df7f52d885 | |||
d5b5faafbb | |||
a318e8588b | |||
51fb252cd8 | |||
86b2f61b56 | |||
232a9fe868 | |||
e8bfe73b1d | |||
ab0d762675 | |||
a6a314e011 | |||
514bdff92e | |||
745e56a3a3 | |||
130fb78b4c | |||
3718ec69ba | |||
4610f4a8c9 | |||
a8062354ec | |||
aac0a5a3a9 | |||
92b9e3400b | |||
bea513f5dd | |||
9d109bf02d | |||
fc45ab48c9 | |||
58e9b02405 | |||
b578fb4840 | |||
f18d9589eb | |||
35c6ec9461 | |||
56d9730d0a | |||
6e18bc8b31 | |||
81756a1af9 | |||
05e1ab1165 | |||
a0ddc5e6eb | |||
dc40b1f93a | |||
d7cc29f2fb | |||
0505e49038 | |||
6425a33ccd | |||
12c5dbd290 | |||
24bc415faf | |||
152e94f229 |
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": []
|
||||||
|
}
|
||||||
|
}
|
@ -8,11 +8,11 @@
|
|||||||
"node" : false,
|
"node" : false,
|
||||||
"rhino" : false,
|
"rhino" : false,
|
||||||
"couch" : false,
|
"couch" : false,
|
||||||
"wsh" : true, // Windows Scripting Host.
|
"wsh" : false, // Windows Scripting Host.
|
||||||
"jquery" : false,
|
"jquery" : false,
|
||||||
|
|
||||||
// Development.
|
// Development.
|
||||||
"debug" : false, // Allow debugger statements e.g. browser breakpoints.
|
"debug" : true, // Allow debugger statements e.g. browser breakpoints.
|
||||||
"devel" : true, // Allow developments statements e.g. `console.log();`.
|
"devel" : true, // Allow developments statements e.g. `console.log();`.
|
||||||
|
|
||||||
// ECMAScript 5.
|
// ECMAScript 5.
|
||||||
@ -25,7 +25,7 @@
|
|||||||
"bitwise" : false, // Prohibit bitwise operators (&, |, ^, etc.).
|
"bitwise" : false, // Prohibit bitwise operators (&, |, ^, etc.).
|
||||||
"boss" : false, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments.
|
"boss" : false, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments.
|
||||||
"curly" : true, // Require {} for every new block or scope.
|
"curly" : true, // Require {} for every new block or scope.
|
||||||
"eqeqeq" : false, // Require triple equals i.e. `===`.
|
"eqeqeq" : true, // Require triple equals i.e. `===`.
|
||||||
"eqnull" : false, // Tolerate use of `== null`.
|
"eqnull" : false, // Tolerate use of `== null`.
|
||||||
"evil" : false, // Tolerate use of `eval`.
|
"evil" : false, // Tolerate use of `eval`.
|
||||||
"expr" : false, // Tolerate `ExpressionStatement` as Programs.
|
"expr" : false, // Tolerate `ExpressionStatement` as Programs.
|
||||||
|
@ -9,13 +9,13 @@
|
|||||||
"HTml5 Video"
|
"HTml5 Video"
|
||||||
],
|
],
|
||||||
"authors": [
|
"authors": [
|
||||||
"Sam Potts <me@sampotts.me>"
|
"Sam Potts <sam@potts.es>"
|
||||||
],
|
],
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"main": [
|
"main": [
|
||||||
"dist/plyr.css",
|
"dist/plyr.css",
|
||||||
"dist/plyr.js",
|
"dist/plyr.js",
|
||||||
"dist/sprite.svg",
|
"dist/plyr.svg",
|
||||||
"src/less/plyr.less",
|
"src/less/plyr.less",
|
||||||
"src/scss/plyr.scss",
|
"src/scss/plyr.scss",
|
||||||
"src/js/plyr.js"
|
"src/js/plyr.js"
|
||||||
@ -27,7 +27,7 @@
|
|||||||
],
|
],
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git://github.com/selz/plyr.git"
|
"url": "git://github.com/sampotts/plyr.git"
|
||||||
},
|
},
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
}
|
}
|
||||||
|
112
changelog.md
112
changelog.md
@ -1,5 +1,105 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## v2.0.16
|
||||||
|
- Fullscreen bug fix (fixes #664)
|
||||||
|
|
||||||
|
## v2.0.15
|
||||||
|
- Demo fix
|
||||||
|
|
||||||
|
## v2.0.14
|
||||||
|
- CDN URL updates. Sorry, still working on V3 as hard as I can...
|
||||||
|
|
||||||
|
## v2.0.13
|
||||||
|
- Repo moved and Vimeo demo fix
|
||||||
|
|
||||||
|
## 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
|
||||||
|
- Fix for Vimeo in IE9 & IE10
|
||||||
|
- Fix for HTML5 elements not firing `ready` event
|
||||||
|
|
||||||
|
## v2.0.4
|
||||||
|
- Fix for Firefox full screen (fixes #343)
|
||||||
|
|
||||||
|
## v2.0.3
|
||||||
|
- Set 'global' keyboard shortcut option to false as default, added `<textarea>` to editable elements to be ignored
|
||||||
|
|
||||||
|
## v2.0.2
|
||||||
|
- Added 'global' keyboard shortcut option
|
||||||
|
|
||||||
|
## v2.0.1
|
||||||
|
- Version bump for NPM (sorry for folks who upgraded to the now deleted v1.9.0 through NPM)
|
||||||
|
|
||||||
|
# v2.0.0
|
||||||
|
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 ;-)
|
||||||
|
|
||||||
|
And some other changes and bug fixes:
|
||||||
|
|
||||||
|
- New `get()` method on the global plyr object to get all instances inside a container
|
||||||
|
- New API methods:
|
||||||
|
- `getOriginal()` to get the original, *unmodified* element plyr was setup on (`<video>`, `<audio>` or empty `<div>` for YouTube and Vimeo)
|
||||||
|
- `getContainer()` to get the players outer wrapper element
|
||||||
|
- `getMedia()` to get the players media element (`<video>`, `<audio>` or empty `<div>` for YouTube and Vimeo)
|
||||||
|
- `getEmbed()` to access the YouTube or Vimeo API directly
|
||||||
|
- `getType()` to get the type of the player
|
||||||
|
- `isReady()` to determine if an instance has completed setup and necessary APIs are loaded (for YouTube / Vimeo)
|
||||||
|
- `on()` to provide an easy way to listen to events
|
||||||
|
- `stop()` to, you guessed it, stop the player
|
||||||
|
- `destroy()` now works correctly for YouTube and Vimeo (fixes #272)
|
||||||
|
- New `destroyed` event when `destroy()` has completed (original element is passed as event.target)
|
||||||
|
- Default volume is now 10 (max) rather than 5
|
||||||
|
- Sprite is only loaded once (fixes #259)
|
||||||
|
- Fixes for Vimeo post message bugs on source change or destroy (fixes #318)
|
||||||
|
- Save caption state in storage (fixes #311)
|
||||||
|
- Added keyboard shortcuts to the current focused player (with `keyboardShortcuts` boolean option to disable) (fixes #309)
|
||||||
|
- Fix for captions bug (fixes #332)
|
||||||
|
- Change to AMD (fixes #298)
|
||||||
|
|
||||||
|
## v1.8.12
|
||||||
|
- Vimeo keyboard focus fix (Fixes #317)
|
||||||
|
- Fix for Vimeo on basic support devices
|
||||||
|
|
||||||
|
## v1.8.11
|
||||||
|
- Fix for keyboard navigation on Vimeo (Fixes #317)
|
||||||
|
- 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)
|
||||||
|
|
||||||
## v1.8.10
|
## v1.8.10
|
||||||
- Fix for seek issues introduced in v1.8.9
|
- Fix for seek issues introduced in v1.8.9
|
||||||
|
|
||||||
@ -35,20 +135,20 @@
|
|||||||
- Improvements for controls hiding and showing on touch devices
|
- Improvements for controls hiding and showing on touch devices
|
||||||
|
|
||||||
## v1.8.2
|
## v1.8.2
|
||||||
- Fixed event bubbling
|
- Fixed event bubbling
|
||||||
|
|
||||||
## v1.8.1
|
## v1.8.1
|
||||||
- Fixed inaccurate log message
|
- Fixed inaccurate log message
|
||||||
|
|
||||||
# v1.8.0
|
# 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
|
- ***(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
|
# v1.7.0
|
||||||
- SASS cleanup (fixes #265)
|
- SASS cleanup (fixes #265)
|
||||||
- Docs tidy up to help quick start (fixes #253)
|
- Docs tidy up to help quick start (fixes #253)
|
||||||
- Fix for issues with data attribute options passing (fixes #257)
|
- 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
|
- Renamed the 'docs' folder to `demo` to avoid confusion - the readme is the docs after all
|
||||||
|
|
||||||
## v1.6.20
|
## v1.6.20
|
||||||
@ -78,7 +178,7 @@
|
|||||||
- Decreased sensitivity and inverted scroll on volume slider (scroll up to increase, down to decrease)
|
- Decreased sensitivity and inverted scroll on volume slider (scroll up to increase, down to decrease)
|
||||||
|
|
||||||
## v1.6.12
|
## v1.6.12
|
||||||
- Fix for undefined buffer error
|
- Fix for undefined buffer error
|
||||||
- Add scroll listener on volume slider (PR #227 bty @igoradamenko)
|
- Add scroll listener on volume slider (PR #227 bty @igoradamenko)
|
||||||
|
|
||||||
## v1.6.11
|
## v1.6.11
|
||||||
@ -120,13 +220,13 @@
|
|||||||
- Other minor bug fixes
|
- Other minor bug fixes
|
||||||
|
|
||||||
## v1.6.1
|
## v1.6.1
|
||||||
- Tooltip changes for accessibility
|
- Tooltip changes for accessibility
|
||||||
|
|
||||||
## v1.6.0
|
## v1.6.0
|
||||||
- New, cleaner, UI:
|
- New, cleaner, UI:
|
||||||
- Controls are now overlaid, maintaining the video's ratio and making sizing easier
|
- Controls are now overlaid, maintaining the video's ratio and making sizing easier
|
||||||
- A large play button can now be overlaid over videos
|
- 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
|
- New play, pause, rewind and fast forward icons
|
||||||
- Flexbox all the things!
|
- 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
|
- 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.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,o=arguments.length;for(i=0;o>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",o=e.Element[i],n=Object,s=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=s.call(e.getAttribute("class")||""),i=t?t.split(/\s+/):[],o=0,n=i.length;n>o;o++)this.push(i[o]);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,o=t.length,n=!1;do e=t[i]+"",-1===c(this,e)&&(this.push(e),n=!0);while(++i<o);n&&this._updateClassName()},u.remove=function(){var e,t,i=arguments,o=0,n=i.length,s=!1;do for(e=i[o]+"",t=c(this,e);-1!==t;)this.splice(t,1),s=!0,t=c(this,e);while(++o<n);s&&this._updateClassName()},u.toggle=function(e,t){e+="";var i=this.contains(e),o=i?t!==!0&&"remove":t!==!1&&"add";return o&&this[o](e),t===!0||t===!1?t:!i},u.toString=function(){return this.join(" ")},n.defineProperty){var p={get:d,enumerable:!0,configurable:!0};try{n.defineProperty(o,t,p)}catch(h){-2146823252===h.number&&(p.enumerable=!1,n.defineProperty(o,t,p))}}else n[i].__defineGetter__&&o.__defineGetter__(t,d)}}(self)),function(){function e(e,t,i){if(e)if(e.classList)e.classList[i?"add":"remove"](t);else{var o=(" "+e.className+" ").replace(/\s+/g," ").replace(" "+t+" ","");e.className=o+(i?" "+t:"")}}function t(t,i){if(t in s&&(i||t!=r)&&(r.length||t!=s.video)){switch(t){case s.video:o.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 s.audio:o.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 s.youtube:o.source({type:"video",title:"View From A Blue Moon",sources:[{src:"bTqVqk7FSmY",type:"youtube"}]});break;case s.vimeo:o.source({type:"video",title:"View From A Blue Moon",sources:[{src:"143418951",type:"vimeo"}]})}r=t;for(var a=n.length-1;a>=0;a--)e(n[a].parentElement,"active",!1);e(document.querySelector('[data-source="'+t+'"]').parentElement,"active",!0)}}document.body.addEventListener("ready",function(e){console.log(e)});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 o=i[0].plyr,n=document.querySelectorAll("[data-source]"),s={video:"video",audio:"audio",youtube:"youtube",vimeo:"vimeo"},r=window.location.hash.replace("#",""),a=window.history&&window.history.pushState,c=n.length-1;c>=0;c--)n[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=s.video),r in s&&history.replaceState({type:r},"",l?"":"#"+r),r!==s.video&&t(r,!0)}}(),document.domain.indexOf("plyr.io")>-1&&(!function(e,t,i,o,n,s,r){e.GoogleAnalyticsObject=n,e[n]=e[n]||function(){(e[n].q=e[n].q||[]).push(arguments)},e[n].l=1*new Date,s=t.createElement(i),r=t.getElementsByTagName(i)[0],s.async=1,s.src=o,r.parentNode.insertBefore(s,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 t=document.createElement("_");if(t.classList.add("c1","c2"),!t.classList.contains("c2")){var e=function(t){var e=DOMTokenList.prototype[t];DOMTokenList.prototype[t]=function(t){var i,o=arguments.length;for(i=0;i<o;i++)t=arguments[i],e.call(this,t)}};e("add"),e("remove")}if(t.classList.toggle("c3",!1),t.classList.contains("c3")){var i=DOMTokenList.prototype.toggle;DOMTokenList.prototype.toggle=function(t,e){return 1 in arguments&&!this.contains(t)==!e?e:i.call(this,t)}}t=null}():!function(t){"use strict";if("Element"in t){var e="classList",i="prototype",o=t.Element[i],s=Object,n=String[i].trim||function(){return this.replace(/^\s+|\s+$/g,"")},r=Array[i].indexOf||function(t){for(var e=0,i=this.length;e<i;e++)if(e in this&&this[e]===t)return e;return-1},a=function(t,e){this.name=t,this.code=DOMException[t],this.message=e},c=function(t,e){if(""===e)throw new a("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(e))throw new a("INVALID_CHARACTER_ERR","String contains an invalid character");return r.call(t,e)},l=function(t){for(var e=n.call(t.getAttribute("class")||""),i=e?e.split(/\s+/):[],o=0,s=i.length;o<s;o++)this.push(i[o]);this._updateClassName=function(){t.setAttribute("class",this.toString())}},u=l[i]=[],d=function(){return new l(this)};if(a[i]=Error[i],u.item=function(t){return this[t]||null},u.contains=function(t){return t+="",c(this,t)!==-1},u.add=function(){var t,e=arguments,i=0,o=e.length,s=!1;do t=e[i]+"",c(this,t)===-1&&(this.push(t),s=!0);while(++i<o);s&&this._updateClassName()},u.remove=function(){var t,e,i=arguments,o=0,s=i.length,n=!1;do for(t=i[o]+"",e=c(this,t);e!==-1;)this.splice(e,1),n=!0,e=c(this,t);while(++o<s);n&&this._updateClassName()},u.toggle=function(t,e){t+="";var i=this.contains(t),o=i?e!==!0&&"remove":e!==!1&&"add";return o&&this[o](t),e===!0||e===!1?e:!i},u.toString=function(){return this.join(" ")},s.defineProperty){var p={get:d,enumerable:!0,configurable:!0};try{s.defineProperty(o,e,p)}catch(h){h.number===-2146823252&&(p.enumerable=!1,s.defineProperty(o,e,p))}}else s[i].__defineGetter__&&o.__defineGetter__(e,d)}}(self)),function(){function t(t,e,i){if(t)if(t.classList)t.classList[i?"add":"remove"](e);else{var o=(" "+t.className+" ").replace(/\s+/g," ").replace(" "+e+" ","");t.className=o+(i?" "+e:"")}}function e(e,i){if(e in n&&(i||e!==r)&&(r.length||e!==n.video)){switch(e){case n.video:o.source({type:"video",title:"View From A Blue Moon",sources:[{src:"https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.mp4",type:"video/mp4"},{src:"https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.webm",type:"video/webm"}],poster:"https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.jpg",tracks:[{kind:"captions",label:"English",srclang:"en",src:"https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.en.vtt","default":!0}]});break;case n.audio:o.source({type:"audio",title:"Kishi Bashi – “It All Began With A Burst”",sources:[{src:"https://cdn.plyr.io/static/demo/Kishi_Bashi_-_It_All_Began_With_a_Burst.mp3",type:"audio/mp3"},{src:"https://cdn.plyr.io/static/demo/Kishi_Bashi_-_It_All_Began_With_a_Burst.ogg",type:"audio/ogg"}]});break;case n.youtube:o.source({type:"video",title:"View From A Blue Moon",sources:[{src:"bTqVqk7FSmY",type:"youtube"}]});break;case n.vimeo:o.source({type:"video",title:"View From A Blue Moon",sources:[{src:"147865858",type:"vimeo"}]})}r=e;for(var a=s.length-1;a>=0;a--)t(s[a].parentElement,"active",!1);t(document.querySelector('[data-source="'+e+'"]').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 o=i[0],s=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=s.length-1;c>=0;c--)s[c].addEventListener("click",function(){var t=this.getAttribute("data-source");e(t),a&&history.pushState({type:t},"","#"+t)});if(window.addEventListener("popstate",function(t){t.state&&"type"in t.state&&e(t.state.type)}),a){var l=!r.length;l&&(r=n.video),r in n&&history.replaceState({type:r},"",l?"":"#"+r),r!==n.video&&e(r,!0)}}(),document.domain.indexOf("plyr.io")>-1&&(!function(t,e,i,o,s,n,r){t.GoogleAnalyticsObject=s,t[s]=t[s]||function(){(t[s].q=t[s].q||[]).push(arguments)},t[s].l=1*new Date,n=e.createElement(i),r=e.getElementsByTagName(i)[0],n.async=1,n.src=o,r.parentNode.insertBefore(n,r)}(window,document,"script","//www.google-analytics.com/analytics.js","ga"),ga("create","UA-40881672-11","auto"),ga("send","pageview"));
|
@ -1,18 +1,25 @@
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="en" class="error">
|
<html lang="en" class="error">
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<title>Doh. Looks like something went wrong.</title>
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
|
|
||||||
<!-- Docs styles -->
|
<head>
|
||||||
<link rel="stylesheet" href="dist/docs.css">
|
<meta charset="utf-8" />
|
||||||
</head>
|
<title>Doh. Looks like something went wrong.</title>
|
||||||
<body>
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<main>
|
|
||||||
<h1>Doh.</h1>
|
<!-- Docs styles -->
|
||||||
<p>Looks like something went wrong.</p>
|
<link rel="stylesheet" href="dist/demo.css">
|
||||||
<a href="http://plyr.io" class="btn btn--primary">Back to plyr.io</a>
|
|
||||||
</main>
|
<!-- Preload -->
|
||||||
</body>
|
<link rel="preload" as="font" crossorigin type="font/woff2" href="https://cdn.plyr.io/static/fonts/avenir-medium.woff2">
|
||||||
</html>
|
<link rel="preload" as="font" crossorigin type="font/woff2" href="https://cdn.plyr.io/static/fonts/avenir-bold.woff2">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<main>
|
||||||
|
<h1>Doh.</h1>
|
||||||
|
<p>Looks like something went wrong.</p>
|
||||||
|
<a href="http://plyr.io" class="btn btn--primary">Back to plyr.io</a>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
167
demo/index.html
167
demo/index.html
@ -1,88 +1,103 @@
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<title>Plyr - A simple HTML5 media player</title>
|
|
||||||
<meta name="description" content="A simple HTML5 media player with custom controls and WebVTT captions.">
|
|
||||||
<meta name="author" content="Sam Potts">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
|
|
||||||
<!-- Styles -->
|
<head>
|
||||||
<link rel="stylesheet" href="../dist/plyr.css">
|
<meta charset="utf-8" />
|
||||||
|
<title>Plyr - A simple HTML5 media player</title>
|
||||||
|
<meta name="description" content="A simple HTML5 media player with custom controls and WebVTT captions.">
|
||||||
|
<meta name="author" content="Sam Potts">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
<!-- Docs styles -->
|
<!-- Styles -->
|
||||||
<link rel="stylesheet" href="dist/demo.css">
|
<link rel="stylesheet" href="../dist/plyr.css">
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<header>
|
|
||||||
<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>
|
|
||||||
<nav>
|
|
||||||
<ul>
|
|
||||||
<li>
|
|
||||||
<a href="https://github.com/selz/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
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="https://twitter.com/intent/tweet?text=A+simple+HTML5+media+player+with+custom+controls+and+WebVTT+captions.&url=http%3A%2F%2Fplyr.io&via=Sam_Potts" target="_blank" class="btn btn--large btn--twitter" data-shr-network="twitter">
|
|
||||||
<svg class="icon"><use xlink:href="#icon-twitter"/></svg>Tweet
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<main role="main" id="main">
|
<!-- Docs styles -->
|
||||||
<nav class="btn__bar">
|
<link rel="stylesheet" href="dist/demo.css">
|
||||||
<ul>
|
|
||||||
<li class="active">
|
|
||||||
<button type="button" class="btn" data-source="video">Video</button>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<button type="button" class="btn" data-source="audio">Audio</button>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<button type="button" class="btn btn--youtube" data-source="youtube"><svg class="icon"><use xlink:href="#icon-youtube"/></svg>YouTube</button>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<button type="button" class="btn btn--vimeo" data-source="vimeo"><svg class="icon"><use xlink:href="#icon-vimeo"/></svg>Vimeo</button>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
<section>
|
|
||||||
<video poster="https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.jpg" 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">
|
|
||||||
|
|
||||||
<!-- Text track file -->
|
<!-- Preload -->
|
||||||
<track kind="captions" label="English" srclang="en" src="https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.en.vtt" default>
|
<link rel="preload" as="font" crossorigin type="font/woff2" href="https://cdn.plyr.io/static/fonts/avenir-medium.woff2">
|
||||||
|
<link rel="preload" as="font" crossorigin type="font/woff2" href="https://cdn.plyr.io/static/fonts/avenir-bold.woff2">
|
||||||
|
</head>
|
||||||
|
|
||||||
<!-- Fallback for browsers that don't support the <video> element -->
|
<body>
|
||||||
<a href="https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.mp4" download>Download</a>
|
<header>
|
||||||
</video>
|
<h1>Plyr</h1>
|
||||||
|
<p>A simple, accessible HTML5 media player by <a href="https://twitter.com/sam_potts" target="_blank">@sam_potts</a></p>
|
||||||
|
<nav>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<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
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="https://twitter.com/intent/tweet?text=A+simple+HTML5+media+player+with+custom+controls+and+WebVTT+captions.&url=http%3A%2F%2Fplyr.io&via=Sam_Potts"
|
||||||
|
target="_blank" class="btn btn--large btn--twitter" data-shr-network="twitter">
|
||||||
|
<svg class="icon">
|
||||||
|
<use xlink:href="#icon-twitter" />
|
||||||
|
</svg>Tweet
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
|
||||||
<ul>
|
<main role="main" id="main">
|
||||||
<li class="plyr__cite plyr__cite--video"><small><a href="http://viewfromabluemoon.com/" target="_blank">View From A Blue Moon</a> © Brainfarm</small></li>
|
<nav class="btn__bar">
|
||||||
<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>
|
<ul>
|
||||||
<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="active">
|
||||||
<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>
|
<button type="button" class="btn" data-source="video">Video</button>
|
||||||
</ul>
|
</li>
|
||||||
</section>
|
<li>
|
||||||
</main>
|
<button type="button" class="btn" data-source="audio">Audio</button>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<button type="button" class="btn btn--youtube" data-source="youtube"><svg class="icon"><use xlink:href="#icon-youtube"/></svg>YouTube</button>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<button type="button" class="btn btn--vimeo" data-source="vimeo"><svg class="icon"><use xlink:href="#icon-vimeo"/></svg>Vimeo</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
<section>
|
||||||
|
<video poster="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.jpg?v1" controls crossorigin>
|
||||||
|
<!-- Video files -->
|
||||||
|
<source src="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.mp4" type="video/mp4">
|
||||||
|
<source src="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.webm" type="video/webm">
|
||||||
|
|
||||||
<!-- Plyr core script -->
|
<!-- Text track file -->
|
||||||
<script src="../dist/plyr.js"></script>
|
<track kind="captions" label="English" srclang="en" src="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.en.vtt"
|
||||||
|
default>
|
||||||
|
|
||||||
<!-- Docs script -->
|
<!-- Fallback for browsers that don't support the <video> element -->
|
||||||
<script src="dist/demo.js"></script>
|
<a href="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.mp4" download>Download</a>
|
||||||
|
</video>
|
||||||
|
|
||||||
<!-- Rangetouch to fix <input type="range"> on touch devices (see https://rangetouch.com) -->
|
<ul>
|
||||||
<script src="https://cdn.rangetouch.com/0.0.9/rangetouch.js" async></script>
|
<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>
|
||||||
|
<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>
|
||||||
|
|
||||||
<!-- Sharing libary (https://shr.one) -->
|
<!-- Plyr core script -->
|
||||||
<script src="https://cdn.shr.one/0.1.9/shr.js"></script>
|
<script src="../dist/plyr.js"></script>
|
||||||
<script>if(window.shr) { window.shr.setup({ count: { classname: 'btn__count' } }); }</script>
|
|
||||||
</body>
|
<!-- Docs script -->
|
||||||
</html>
|
<script src="dist/demo.js"></script>
|
||||||
|
|
||||||
|
<!-- Rangetouch to fix <input type="range"> on touch devices (see https://rangetouch.com) -->
|
||||||
|
<script src="https://cdn.rangetouch.com/1.0.1/rangetouch.js" async></script>
|
||||||
|
|
||||||
|
<!-- Sharing libary (https://shr.one) -->
|
||||||
|
<script src="https://cdn.shr.one/1.0.1/shr.js"></script>
|
||||||
|
<script>
|
||||||
|
if (window.shr) { window.shr.setup({ count: { classname: 'btn__count' } }); }
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
@ -7,73 +7,73 @@
|
|||||||
/*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
|
||||||
var instances = plyr.setup({
|
var instances = plyr.setup({
|
||||||
debug: true,
|
debug: true,
|
||||||
title: 'Video demo',
|
title: "Video demo",
|
||||||
iconUrl: '../dist/plyr.svg',
|
iconUrl: "../dist/plyr.svg",
|
||||||
tooltips: {
|
tooltips: {
|
||||||
controls: true
|
controls: true
|
||||||
},
|
},
|
||||||
captions: {
|
captions: {
|
||||||
defaultActive: true
|
defaultActive: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
plyr.loadSprite('dist/demo.svg');
|
plyr.loadSprite("dist/demo.svg");
|
||||||
|
|
||||||
// Plyr returns an array regardless
|
// Plyr returns an array regardless
|
||||||
var player = instances[0].plyr;
|
var player = instances[0];
|
||||||
|
|
||||||
// Setup type toggle
|
// Setup type toggle
|
||||||
var buttons = document.querySelectorAll('[data-source]'),
|
var buttons = document.querySelectorAll("[data-source]"),
|
||||||
types = {
|
types = {
|
||||||
video: 'video',
|
video: "video",
|
||||||
audio: 'audio',
|
audio: "audio",
|
||||||
youtube: 'youtube',
|
youtube: "youtube",
|
||||||
vimeo: 'vimeo'
|
vimeo: "vimeo"
|
||||||
},
|
},
|
||||||
currentType = window.location.hash.replace('#', ''),
|
currentType = window.location.hash.replace("#", ""),
|
||||||
historySupport = (window.history && window.history.pushState);
|
historySupport = window.history && window.history.pushState;
|
||||||
|
|
||||||
// Bind to each button
|
// Bind to each button
|
||||||
for (var i = buttons.length - 1; i >= 0; i--) {
|
for (var i = buttons.length - 1; i >= 0; i--) {
|
||||||
buttons[i].addEventListener('click', function() {
|
buttons[i].addEventListener("click", function() {
|
||||||
var type = this.getAttribute('data-source');
|
var type = this.getAttribute("data-source");
|
||||||
|
|
||||||
newSource(type);
|
newSource(type);
|
||||||
|
|
||||||
if (historySupport) {
|
if (historySupport) {
|
||||||
history.pushState({ 'type': type }, '', '#' + type);
|
history.pushState({ type: type }, "", "#" + type);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// List for backwards/forwards
|
// List for backwards/forwards
|
||||||
window.addEventListener('popstate', function(event) {
|
window.addEventListener("popstate", function(event) {
|
||||||
if(event.state && 'type' in event.state) {
|
if (event.state && "type" in event.state) {
|
||||||
newSource(event.state.type);
|
newSource(event.state.type);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// On load
|
// On load
|
||||||
if(historySupport) {
|
if (historySupport) {
|
||||||
var video = !currentType.length;
|
var video = !currentType.length;
|
||||||
|
|
||||||
// If there's no current type set, assume video
|
// If there's no current type set, assume video
|
||||||
if(video) {
|
if (video) {
|
||||||
currentType = types.video;
|
currentType = types.video;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace current history state
|
// Replace current history state
|
||||||
if(currentType in types) {
|
if (currentType in types) {
|
||||||
history.replaceState({ 'type': currentType }, '', (video ? '' : '#' + currentType));
|
history.replaceState({ type: currentType }, "", video ? "" : "#" + currentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it's not video, load the source
|
// If it's not video, load the source
|
||||||
if(currentType !== types.video) {
|
if (currentType !== types.video) {
|
||||||
newSource(currentType, true);
|
newSource(currentType, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -82,11 +82,10 @@
|
|||||||
function toggleClass(element, className, state) {
|
function toggleClass(element, className, state) {
|
||||||
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 : '');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -94,68 +93,78 @@
|
|||||||
// 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(type) {
|
switch (type) {
|
||||||
case types.video:
|
case types.video:
|
||||||
player.source({
|
player.source({
|
||||||
type: 'video',
|
type: "video",
|
||||||
title: 'View From A Blue Moon',
|
title: "View From A Blue Moon",
|
||||||
sources: [{
|
sources: [
|
||||||
src: 'https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.mp4',
|
{
|
||||||
type: 'video/mp4'
|
src: "https://cdn.plyr.io/static/demo/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'
|
src: "https://cdn.plyr.io/static/demo/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',
|
poster: "https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.jpg",
|
||||||
label: 'English',
|
tracks: [
|
||||||
srclang:'en',
|
{
|
||||||
src: 'https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.en.vtt',
|
kind: "captions",
|
||||||
default: true
|
label: "English",
|
||||||
}]
|
srclang: "en",
|
||||||
|
src: "https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.en.vtt",
|
||||||
|
default: true
|
||||||
|
}
|
||||||
|
]
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case types.audio:
|
case types.audio:
|
||||||
player.source({
|
player.source({
|
||||||
type: 'audio',
|
type: "audio",
|
||||||
title: 'Kishi Bashi – “It All Began With A Burst”',
|
title: "Kishi Bashi – “It All Began With A Burst”",
|
||||||
sources: [{
|
sources: [
|
||||||
src: 'https://cdn.selz.com/plyr/1.5/Kishi_Bashi_-_It_All_Began_With_a_Burst.mp3',
|
{
|
||||||
type: 'audio/mp3'
|
src: "https://cdn.plyr.io/static/demo/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'
|
src: "https://cdn.plyr.io/static/demo/Kishi_Bashi_-_It_All_Began_With_a_Burst.ogg",
|
||||||
}]
|
type: "audio/ogg"
|
||||||
|
}
|
||||||
|
]
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case types.youtube:
|
case types.youtube:
|
||||||
player.source({
|
player.source({
|
||||||
type: 'video',
|
type: "video",
|
||||||
title: 'View From A Blue Moon',
|
title: "View From A Blue Moon",
|
||||||
sources: [{
|
sources: [
|
||||||
src: 'bTqVqk7FSmY',
|
{
|
||||||
type: 'youtube'
|
src: "bTqVqk7FSmY",
|
||||||
}]
|
type: "youtube"
|
||||||
|
}
|
||||||
|
]
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case types.vimeo:
|
case types.vimeo:
|
||||||
player.source({
|
player.source({
|
||||||
type: 'video',
|
type: "video",
|
||||||
title: 'View From A Blue Moon',
|
title: "View From A Blue Moon",
|
||||||
sources: [{
|
sources: [
|
||||||
src: '143418951',
|
{
|
||||||
type: 'vimeo'
|
src: "147865858",
|
||||||
}]
|
type: "vimeo"
|
||||||
|
}
|
||||||
|
]
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -165,21 +174,30 @@
|
|||||||
|
|
||||||
// Remove active classes
|
// Remove active classes
|
||||||
for (var x = buttons.length - 1; x >= 0; x--) {
|
for (var x = buttons.length - 1; x >= 0; x--) {
|
||||||
toggleClass(buttons[x].parentElement, 'active', false);
|
toggleClass(buttons[x].parentElement, "active", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set active on parent
|
// Set active on parent
|
||||||
toggleClass(document.querySelector('[data-source="'+ type +'"]').parentElement, 'active', true);
|
toggleClass(document.querySelector('[data-source="' + type + '"]').parentElement, "active", true);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
// Google analytics
|
// Google analytics
|
||||||
// For demo site (http://[www.]plyr.io) only
|
// For demo site (http://[www.]plyr.io) only
|
||||||
if(document.domain.indexOf('plyr.io') > -1) {
|
if (document.domain.indexOf("plyr.io") > -1) {
|
||||||
(function(i,s,o,g,r,a,m){i.GoogleAnalyticsObject=r;i[r]=i[r]||function(){
|
(function(i, s, o, g, r, a, m) {
|
||||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
i.GoogleAnalyticsObject = r;
|
||||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
(i[r] =
|
||||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
i[r] ||
|
||||||
ga('create', 'UA-40881672-11', 'auto');
|
function() {
|
||||||
ga('send', 'pageview');
|
(i[r].q = i[r].q || []).push(arguments);
|
||||||
|
}),
|
||||||
|
(i[r].l = 1 * new Date());
|
||||||
|
(a = s.createElement(o)), (m = s.getElementsByTagName(o)[0]);
|
||||||
|
a.async = 1;
|
||||||
|
a.src = g;
|
||||||
|
m.parentNode.insertBefore(a, m);
|
||||||
|
})(window, document, "script", "//www.google-analytics.com/analytics.js", "ga");
|
||||||
|
ga("create", "UA-40881672-11", "auto");
|
||||||
|
ga("send", "pageview");
|
||||||
}
|
}
|
||||||
|
@ -39,9 +39,10 @@ header {
|
|||||||
|
|
||||||
// Sections
|
// Sections
|
||||||
section {
|
section {
|
||||||
padding-bottom: @padding-base;
|
max-width: @example-width-video;
|
||||||
|
margin: 0 auto @padding-base;
|
||||||
|
|
||||||
@media (min-width: @screen-sm) {
|
@media (min-width: @screen-sm) {
|
||||||
padding-bottom: (@padding-base * 2);
|
margin-bottom: (@padding-base * 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,11 +2,6 @@
|
|||||||
// Examples
|
// Examples
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
|
||||||
section {
|
|
||||||
margin: 0 auto @padding-base;
|
|
||||||
max-width: @example-width-video;
|
|
||||||
}
|
|
||||||
|
|
||||||
// For non supported browsers
|
// For non supported browsers
|
||||||
video {
|
video {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
|
@ -4,15 +4,17 @@
|
|||||||
|
|
||||||
@font-face {
|
@font-face {
|
||||||
font-family: "Avenir";
|
font-family: "Avenir";
|
||||||
src: url("//cdn.plyr.io/fonts/avenir-medium.woff2") format("woff2"),
|
src: url("//cdn.plyr.io/static/fonts/avenir-medium.woff2") format("woff2"),
|
||||||
url("//cdn.plyr.io/fonts/avenir-medium.woff") format("woff");
|
url("//cdn.plyr.io/static/fonts/avenir-medium.woff") format("woff");
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
font-weight: @font-weight-base;
|
font-weight: @font-weight-base;
|
||||||
|
font-display: swap;
|
||||||
}
|
}
|
||||||
@font-face {
|
@font-face {
|
||||||
font-family: "Avenir";
|
font-family: "Avenir";
|
||||||
src: url("//cdn.plyr.io/fonts/avenir-bold.woff2") format("woff2"),
|
src: url("//cdn.plyr.io/static/fonts/avenir-bold.woff2") format("woff2"),
|
||||||
url("//cdn.plyr.io/fonts/avenir-bold.woff") format("woff");
|
url("//cdn.plyr.io/static/fonts/avenir-bold.woff") format("woff");
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
font-weight: @font-weight-bold;
|
font-weight: @font-weight-bold;
|
||||||
}
|
font-display: swap;
|
||||||
|
}
|
||||||
|
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
30
gulpfile.js
30
gulpfile.js
@ -77,20 +77,20 @@ function loadJSON(path) {
|
|||||||
// Create a file from a string
|
// Create a file from a string
|
||||||
// http://stackoverflow.com/questions/23230569/how-do-you-create-a-file-from-a-string-in-gulp
|
// http://stackoverflow.com/questions/23230569/how-do-you-create-a-file-from-a-string-in-gulp
|
||||||
function createFile(filename, string) {
|
function createFile(filename, string) {
|
||||||
var src = require('stream').Readable({
|
var src = require('stream').Readable({
|
||||||
objectMode: true
|
objectMode: true
|
||||||
});
|
});
|
||||||
src._read = function () {
|
src._read = function () {
|
||||||
this.push(new gutil.File({
|
this.push(new gutil.File({
|
||||||
cwd: "",
|
cwd: "",
|
||||||
base: "",
|
base: "",
|
||||||
path: filename,
|
path: filename,
|
||||||
contents: new Buffer(string),
|
contents: new Buffer(string),
|
||||||
// stats also required for some functions
|
// stats also required for some functions
|
||||||
// https://nodejs.org/api/fs.html#fs_class_fs_stats
|
// https://nodejs.org/api/fs.html#fs_class_fs_stats
|
||||||
stat: {
|
stat: {
|
||||||
size: string.length
|
size: string.length
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
this.push(null);
|
this.push(null);
|
||||||
}
|
}
|
||||||
@ -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
|
||||||
|
90
package.json
90
package.json
@ -1,51 +1,43 @@
|
|||||||
{
|
{
|
||||||
"name": "plyr",
|
"name": "plyr",
|
||||||
"version": "1.8.10",
|
"version": "2.0.16",
|
||||||
"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",
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"gulp": "^3.9.1",
|
"gulp": "^3.9.1",
|
||||||
"gulp-autoprefixer": "^3.1.0",
|
"gulp-autoprefixer": "^3.1.0",
|
||||||
"gulp-clean-css": "^2.0.6",
|
"gulp-clean-css": "^2.0.6",
|
||||||
"gulp-concat": "^2.3.3",
|
"gulp-concat": "^2.3.3",
|
||||||
"gulp-less": "^3.0.5",
|
"gulp-less": "^3.0.5",
|
||||||
"gulp-open": "^2.0.0",
|
"gulp-open": "^2.0.0",
|
||||||
"gulp-rename": "^1.2.0",
|
"gulp-rename": "^1.2.0",
|
||||||
"gulp-replace": "^0.5.3",
|
"gulp-replace": "^0.5.3",
|
||||||
"gulp-s3": "^0.3.0",
|
"gulp-s3": "^0.3.0",
|
||||||
"gulp-sass": "^2.3.1",
|
"gulp-sass": "^2.3.1",
|
||||||
"gulp-size": "^2.1.0",
|
"gulp-size": "^2.1.0",
|
||||||
"gulp-svgmin": "^1.2.2",
|
"gulp-svgmin": "^1.2.2",
|
||||||
"gulp-svgstore": "^5.0.5",
|
"gulp-svgstore": "^5.0.5",
|
||||||
"gulp-uglify": "^1.5.3",
|
"gulp-uglify": "^1.5.3",
|
||||||
"gulp-util": "^3.0.7",
|
"gulp-util": "^3.0.7",
|
||||||
"run-sequence": "^1.1.5",
|
"run-sequence": "^1.1.5",
|
||||||
"through2": "^2.0.1"
|
"through2": "^2.0.1"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": ["HTML5 Video", "HTML5 Audio", "Media Player", "DASH", "Shaka", "WordPress", "HLS"],
|
||||||
"HTML5 Video",
|
"repository": {
|
||||||
"HTML5 Audio",
|
"type": "git",
|
||||||
"Media Player",
|
"url": "git://github.com/sampotts/plyr.git"
|
||||||
"DASH",
|
},
|
||||||
"Shaka",
|
"license": "MIT",
|
||||||
"WordPress",
|
"bugs": {
|
||||||
"HLS"
|
"url": "https://github.com/sampotts/plyr/issues"
|
||||||
],
|
},
|
||||||
"repository": {
|
"directories": {
|
||||||
"type": "git",
|
"doc": "readme.md"
|
||||||
"url": "git://github.com/selz/plyr.git"
|
},
|
||||||
},
|
"scripts": {
|
||||||
"license": "MIT",
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
"bugs": {
|
},
|
||||||
"url": "https://github.com/selz/plyr/issues"
|
"author": "Sam Potts <sam@potts.es>"
|
||||||
},
|
|
||||||
"directories": {
|
|
||||||
"doc": "readme.md"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
|
||||||
},
|
|
||||||
"author": "Sam Potts <sam@selz.com>"
|
|
||||||
}
|
}
|
||||||
|
577
readme.md
577
readme.md
@ -1,9 +1,11 @@
|
|||||||
# 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)
|
||||||
|
|
||||||
## Why?
|
## Why?
|
||||||
We wanted a lightweight, accessible and customizable media player that supports [*modern*](#browser-support) browsers. Sure, there are many other players out there but we wanted to keep things simple, using the right elements for the job.
|
We wanted a lightweight, accessible and customizable media player that supports [*modern*](#browser-support) browsers. Sure, there are many other players out there but we wanted to keep things simple, using the right elements for the job.
|
||||||
@ -13,31 +15,42 @@ We wanted a lightweight, accessible and customizable media player that supports
|
|||||||
- **Lightweight** - under 10KB minified and gzipped
|
- **Lightweight** - under 10KB minified and gzipped
|
||||||
- **[Customisable](#html)** - make the player look how you want with the markup you want
|
- **[Customisable](#html)** - make the player look how you want with the markup you want
|
||||||
- **Semantic** - uses the *right* elements. `<input type="range">` for volume and `<progress>` for progress and well, `<button>`s for buttons. There's no `<span>` or `<a href="#">` button hacks
|
- **Semantic** - uses the *right* elements. `<input type="range">` for volume and `<progress>` for progress and well, `<button>`s for buttons. There's no `<span>` or `<a href="#">` button hacks
|
||||||
- **Responsive** - as you'd expect these days
|
- **Responsive** - works with any screen size
|
||||||
- **HTML Video & Audio** - support for both formats
|
- **HTML Video & Audio** - support for both formats
|
||||||
- **[Embedded Video](#embeds)** - support for YouTube and Vimeo video playback
|
- **[Embedded Video](#embeds)** - support for YouTube and Vimeo video playback
|
||||||
|
- **[Streaming](#streaming)** - support for hls.js, Shaka and dash.js streaming playback
|
||||||
- **[API](#api)** - toggle playback, volume, seeking, and more
|
- **[API](#api)** - toggle playback, volume, seeking, and more
|
||||||
- **[Universal events](#events)** - no messing around with Vimeo and YouTube APIs, all events are universal across formats
|
- **[Events](#events)** - no messing around with Vimeo and YouTube APIs, all events are standardized across formats
|
||||||
- **[Fullscreen](#fullscreen)** - supports native fullscreen with fallback to "full window" modes
|
- **[Fullscreen](#fullscreen)** - supports native fullscreen with fallback to "full window" modes
|
||||||
|
- **[Shortcuts](#shortcuts)** - supports keyboard shortcuts
|
||||||
- **i18n support** - support for internationalization of controls
|
- **i18n support** - support for internationalization of controls
|
||||||
- **No dependencies** - written in "vanilla" JavaScript, no jQuery required
|
- **No dependencies** - written in "vanilla" JavaScript, no jQuery required
|
||||||
- **SASS and LESS source** - to include in your build process
|
- **SASS and LESS** - to include in your build processes
|
||||||
- **[Streaming](#streaming)** - support for hls.js, Shaka and dash.js streaming playback
|
|
||||||
|
|
||||||
Oh and yes, it works with Bootstrap.
|
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
|
||||||
- Streaming
|
- Playback speed selection
|
||||||
- Playback speed
|
- 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
|
||||||
|
|
||||||
@ -75,10 +88,10 @@ ember addon:install ember-cli-plyr
|
|||||||
More info is on [npm](https://www.npmjs.com/package/ember-cli-plyr) and [GitHub](https://github.com/louisrudner/ember-cli-plyr)
|
More info is on [npm](https://www.npmjs.com/package/ember-cli-plyr) and [GitHub](https://github.com/louisrudner/ember-cli-plyr)
|
||||||
|
|
||||||
## Quick setup
|
## Quick setup
|
||||||
Here's a quick run through on getting up and running.
|
Here's a quick run through on getting up and running. There's also a [demo on Codepen](http://codepen.io/sampotts/pen/jARJYp).
|
||||||
|
|
||||||
### HTML
|
### HTML
|
||||||
Plyr extends upon the standard HTML5 markup so that's all you need for those types.
|
Plyr extends upon the standard HTML5 markup so that's all you need for those types. More info on advanced HTML markup can be found under [initialising](#initialising).
|
||||||
|
|
||||||
#### HTML5 Video
|
#### HTML5 Video
|
||||||
```html
|
```html
|
||||||
@ -105,23 +118,26 @@ 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).
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<script src="path/to/plyr.js"></script>
|
<script src="path/to/plyr.js"></script>
|
||||||
<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/1.8.10/plyr.js"></script>
|
<script src="https://cdn.plyr.io/2.0.16/plyr.js"></script>
|
||||||
```
|
```
|
||||||
|
|
||||||
### CSS
|
### CSS
|
||||||
@ -131,19 +147,19 @@ 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/1.8.10/plyr.css">
|
<link rel="stylesheet" href="https://cdn.plyr.io/2.0.16/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/1.8.10/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.16/plyr.svg`.
|
||||||
|
|
||||||
## Advanced
|
## Advanced
|
||||||
|
|
||||||
### LESS & SASS/SCSS
|
### LESS & SASS/SCSS
|
||||||
You can use `plyr.less` or `plyr.scss` file included in `/src` as part of your build and change variables to suit your design. The LESS and SASS require you to use the [autoprefixer](https://www.npmjs.com/package/gulp-autoprefixer) plugin (you should already) as all declerations use the W3C definitions - e.g. `appearance: none;` will be prefixed to `-webkit-appearance: none;` by autoprefixer.
|
You can use `plyr.less` or `plyr.scss` file included in `/src` as part of your build and change variables to suit your design. The LESS and SASS require you to use the [autoprefixer](https://www.npmjs.com/package/gulp-autoprefixer) plugin (you should already) as all declerations use the W3C definitions - e.g. `appearance: none;` will be prefixed to `-webkit-appearance: none;` by autoprefixer.
|
||||||
|
|
||||||
The HTML markup uses the BEM methodology with `plyr` as the block, e.g. `.plyr__controls`. You can change the class hooks in the options to match any custom CSS you write. Check out the JavaScript source for more on this.
|
The HTML markup uses the BEM methodology with `plyr` as the block, e.g. `.plyr__controls`. You can change the class hooks in the options to match any custom CSS you write. Check out the JavaScript source for more on this.
|
||||||
|
|
||||||
@ -151,7 +167,7 @@ The HTML markup uses the BEM methodology with `plyr` as the block, e.g. `.plyr__
|
|||||||
The icons used in the Plyr controls are loaded in an SVG sprite. The sprite is automatically loaded from our CDN by default. If you already have an icon build system in place, you can include the source plyr icons (see `/src/sprite` for source icons).
|
The icons used in the Plyr controls are loaded in an SVG sprite. The sprite is automatically loaded from our CDN by default. If you already have an icon build system in place, you can include the source plyr icons (see `/src/sprite` for source icons).
|
||||||
|
|
||||||
#### Using the `iconUrl` option
|
#### Using the `iconUrl` option
|
||||||
You can however specify your own `iconUrl` option and Plyr will determine if the url is absolute and requires loading by AJAX/CORS due to current browser limitations or if it's a relative path, just use the path directly.
|
You can however specify your own `iconUrl` option and Plyr will determine if the url is absolute and requires loading by AJAX/CORS due to current browser limitations or if it's a relative path, just use the path directly.
|
||||||
|
|
||||||
If you're using the `<base>` tag on your site, you may need to use something like this:
|
If you're using the `<base>` tag on your site, you may need to use something like this:
|
||||||
[svgfixer.js](https://gist.github.com/leonderijke/c5cf7c5b2e424c0061d2)
|
[svgfixer.js](https://gist.github.com/leonderijke/c5cf7c5b2e424c0061d2)
|
||||||
@ -172,7 +188,7 @@ WebVTT captions are supported. To add a caption track, check the HTML example ab
|
|||||||
|
|
||||||
#### Initialising
|
#### Initialising
|
||||||
|
|
||||||
By default, Plyr looks for all `<video>`, `<audio>` and `[data-type]` elements with the document and initialises on any found. You can specify other options, including a different NodeList, HTMLElement or string selector as below:
|
By default, `setup()` will find all `<video>`, `<audio>` and `[data-type]` elements with the document and initialises on any found. Each target media element found will be wrapped in a `<div>` for styling and setup individually. You can specify a variety of arguments to `setup()` to use, including a different NodeList, HTMLElement, Array of HTMLElements or string selector as below:
|
||||||
|
|
||||||
Passing a [NodeList](https://developer.mozilla.org/en-US/docs/Web/API/NodeList):
|
Passing a [NodeList](https://developer.mozilla.org/en-US/docs/Web/API/NodeList):
|
||||||
```javascript
|
```javascript
|
||||||
@ -184,22 +200,30 @@ Passing a [HTMLElement](https://developer.mozilla.org/en/docs/Web/API/HTMLElemen
|
|||||||
plyr.setup(document.querySelector('.js-player'), options);
|
plyr.setup(document.querySelector('.js-player'), options);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Passing an [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) of [HTMLElement](https://developer.mozilla.org/en/docs/Web/API/HTMLElement)s:
|
||||||
|
```javascript
|
||||||
|
plyr.setup([
|
||||||
|
document.querySelector('.js-player-1'),
|
||||||
|
document.querySelector('.js-player-2')
|
||||||
|
], options);
|
||||||
|
```
|
||||||
|
|
||||||
Passing a [string selector](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll):
|
Passing a [string selector](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll):
|
||||||
```javascript
|
```javascript
|
||||||
plyr.setup('.js-player', options);
|
plyr.setup('.js-player', options);
|
||||||
```
|
```
|
||||||
|
|
||||||
The NodeList, HTMLElement or string selector can be the target `<video>`, `<audio>` or `[data-type]` (for embeds) element or a container element. If a container has several media elements inside, each media element will be wrapped in a `<div>` and setup individually.
|
The NodeList, HTMLElement or string selector can be the target `<video>`, `<audio>` or `[data-type]` (for embeds) element itself or a container element.
|
||||||
|
|
||||||
Passing just the options object:
|
Passing just the options object:
|
||||||
```javascript
|
```javascript
|
||||||
plyr.setup(options);
|
plyr.setup(options);
|
||||||
```
|
```
|
||||||
|
|
||||||
`setup()` will return an array of all the elements Plyr was setup on. The `plyr` object can be accessed on these elements and used for the API.
|
`setup()` will return an array of *instances* that can be used with the [API](#api) methods. See the [API](#api) section for more info.
|
||||||
|
|
||||||
#### RangeTouch
|
#### RangeTouch
|
||||||
Some touch browsers (particularly Mobile Safari on iOS) seem to have issues with `<input type="range">` elements whereby touching the track to set the value doesn't work and sliding the thumb can be tricky. To combat this, I've created [RangeTouch](https://rangetouch.com) which I'd recommend including in your solution. It's a tiny script with a nice benefit for users on touch devices.
|
Some touch browsers (particularly Mobile Safari on iOS) seem to have issues with `<input type="range">` elements whereby touching the track to set the value doesn't work and sliding the thumb can be tricky. To combat this, I've created [RangeTouch](https://rangetouch.com) which I'd recommend including in your solution. It's a tiny script with a nice benefit for users on touch devices.
|
||||||
|
|
||||||
#### Options
|
#### Options
|
||||||
Options must be passed as an object to the `setup()` method as above or as JSON in `data-plyr` attribute on each of your target elements:
|
Options must be passed as an object to the `setup()` method as above or as JSON in `data-plyr` attribute on each of your target elements:
|
||||||
@ -262,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>
|
||||||
@ -310,6 +340,12 @@ Note the single quotes encapsulating the JSON and double quotes on the object ke
|
|||||||
<td><code>false</code></td>
|
<td><code>false</code></td>
|
||||||
<td>This will restore and *reload* HTML5 video once playback is complete. Note: depending on the browser caching, this may result in the video downloading again (or parts of it). Use with caution.</td>
|
<td>This will restore and *reload* HTML5 video once playback is complete. Note: depending on the browser caching, this may result in the video downloading again (or parts of it). Use with caution.</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>keyboardShortcuts</code></td>
|
||||||
|
<td>Object</td>
|
||||||
|
<td><code>{ focused: true, global: false }</code></td>
|
||||||
|
<td>Enable <a href="#shortcuts">keyboard shortcuts</a> for focused players only or globally as well (this will only work if there's one player in the document)</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>tooltips</code></td>
|
<td><code>tooltips</code></td>
|
||||||
<td>Object</td>
|
<td>Object</td>
|
||||||
@ -406,29 +442,36 @@ Note the single quotes encapsulating the JSON and double quotes on the object ke
|
|||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
#### Getting the `plyr` instance
|
### Instance
|
||||||
A `plyr` object is added to any element that Plyr is initialized on. You can then control the player by accessing methods in the `plyr` object.
|
|
||||||
|
|
||||||
There are two ways to access the instance, firstly you re-query the element container you used for setup (e.g. `.js-player`) like so:
|
The easiest way to access the plyr instances is to store the return value from your call to `setup()`:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var player = document.querySelector('.js-player').plyr;
|
var players = plyr.setup('.js-player');
|
||||||
```
|
```
|
||||||
|
|
||||||
You can listen for the `setup` [event](#events) on the container, after which the `plyr` key will be available and also passed in the to your callback (in the `plyr` key of the event object).
|
This will return an array of all instances that were setup. Another way is to use `plyr.get()` to get all instances within a given container, for example:
|
||||||
|
|
||||||
The other method is using the return value from the call to `setup()`. An array of instances is returned so you need to use an index:
|
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var player = plyr.setup('.js-player')[0].plyr;
|
var players = plyr.get('.js-player');
|
||||||
```
|
```
|
||||||
|
|
||||||
This will return an array of plyr instances that were setup, so you need to specify the index of the instance you want or loop through of course. This is less useful if you are setting up multiple instances.
|
If no argument is passed, it will find all instances in the current document. This will return an array of all instances that were found in the given selector.
|
||||||
|
|
||||||
Once you have your instance, you can use the API methods below on it. For example to pause it:
|
A final option is to access the instance through the event handlers:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
player.pause();
|
instance.on('ready', function(event) {
|
||||||
|
var instance = event.detail.plyr;
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### Methods
|
||||||
|
|
||||||
|
Once you have your instances, you can use the API methods below on it. For example to pause the first player:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
players[0].pause();
|
||||||
```
|
```
|
||||||
|
|
||||||
Here's a list of the methods supported:
|
Here's a list of the methods supported:
|
||||||
@ -442,6 +485,36 @@ Here's a list of the methods supported:
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td><code>getContainer()</code></td>
|
||||||
|
<td>—</td>
|
||||||
|
<td>Get the players outer container element that is automatically injected.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>getMedia()</code></td>
|
||||||
|
<td>—</td>
|
||||||
|
<td>Get the media element (<code>>video<</code>, <code>>audio<</code> or <code>>div<</code> for YouTube or Vimeo).</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>getEmbed()</code></td>
|
||||||
|
<td>—</td>
|
||||||
|
<td>Get the [embed](#embed) API to access those methods - either YouTube or Vimeo.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>getType()</code></td>
|
||||||
|
<td>—</td>
|
||||||
|
<td>Get the type - 'video', 'audio', 'youtube' or 'vimeo'.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>isReady()</code></td>
|
||||||
|
<td>—</td>
|
||||||
|
<td>Determine if the player is loaded and UI ready.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>on()</code></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. This is chainable.</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>play()</code></td>
|
<td><code>play()</code></td>
|
||||||
<td>—</td>
|
<td>—</td>
|
||||||
@ -452,7 +525,12 @@ Here's a list of the methods supported:
|
|||||||
<td>—</td>
|
<td>—</td>
|
||||||
<td>Pauses the media</td>
|
<td>Pauses the media</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
<td><code>stop()</code></td>
|
||||||
|
<td>—</td>
|
||||||
|
<td>Stops the media</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
<td><code>restart()</code></td>
|
<td><code>restart()</code></td>
|
||||||
<td>—</td>
|
<td>—</td>
|
||||||
<td>Restarts playback</td>
|
<td>Restarts playback</td>
|
||||||
@ -472,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>
|
||||||
@ -482,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>
|
||||||
@ -531,17 +634,7 @@ Here's a list of the methods supported:
|
|||||||
<tr>
|
<tr>
|
||||||
<td><code>destroy()</code></td>
|
<td><code>destroy()</code></td>
|
||||||
<td>—</td>
|
<td>—</td>
|
||||||
<td>Destroys the plyr UI and any media event listeners, effectively restoring to the previous state before <code>setup()</code> was called.</td>
|
<td>Restores the original element, reversing the effects of <code>setup()</code>.</td>
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>restore()</code></td>
|
|
||||||
<td>—</td>
|
|
||||||
<td>Reverses the effects of the <code>destroy()</code> method, restoring the UI and listeners.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>getCurrentTime()</code></td>
|
|
||||||
<td>—</td>
|
|
||||||
<td>Will return a float with the current time in seconds.</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
@ -604,6 +697,8 @@ player.source({
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Note: `src` can be the video ID or URL
|
||||||
|
|
||||||
Vimeo example
|
Vimeo example
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
@ -617,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>
|
||||||
@ -636,12 +733,12 @@ Some more details on the object parameters
|
|||||||
<tr>
|
<tr>
|
||||||
<td><code>title</code></td>
|
<td><code>title</code></td>
|
||||||
<td>String</td>
|
<td>String</td>
|
||||||
<td>Title of the new media. Used for the aria labelling.</td>
|
<td>Title of the new media. Used for the `aria-label` attribute on the play button, and outer container.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<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>
|
||||||
@ -657,173 +754,233 @@ Some more details on the object parameters
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
## Events
|
## Events
|
||||||
You can listen for events on the target element you setup Plyr on (see example under the table). Some events only apply to HTML5 audio and video.
|
You can listen for events on the target element you setup Plyr on (see example under the table). Some events only apply to HTML5 audio and video. Using your reference to the instance, you can use the `on()` API method or `addEventListener()`. Access to the API can be obtained this way through the `event.detail.plyr` property. Here's an example:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
instance.on('ready', function(event) {
|
||||||
|
var instance = event.detail.plyr;
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
These events also bubble up the DOM. The event target will be the container element.
|
||||||
|
|
||||||
<table class="table" width="100%">
|
<table class="table" width="100%">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th width="20%">Event name</th>
|
<th width="20%">Event name</th>
|
||||||
<th width="20%">HTML5 only</th>
|
<th width="20%">HTML5 only</th>
|
||||||
<th width="60%">Description</th>
|
<th width="60%">Description</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>canplay</code></td>
|
<td><code>setup</code></td>
|
||||||
<td>✔</td>
|
<td></td>
|
||||||
<td>Sent when enough data is available that the media can be played, at least for a couple of frames. This corresponds to the <code>HAVE_ENOUGH_DATA</code> <code>readyState</code>.</td>
|
<td>When an initial setup has completed</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>canplaythrough</code></td>
|
<td><code>ready</code></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>Sent when the ready state changes to <code>CAN_PLAY_THROUGH</code>, indicating that the entire media can be played without interruption, assuming the download rate remains at least at the current level. <strong>Note</strong>: Manually setting the <code>currentTime</code> will eventually fire a <code>canplaythrough</code> event in firefox. Other browsers might not fire this event.</td>
|
<td>Triggered when the instance is ready for API use and external APIs are ready (in the case of YouTube and Vimeo).</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>emptied</code></td>
|
<td><code>canplay</code></td>
|
||||||
<td>✔</td>
|
<td>✔</td>
|
||||||
<td>The media has become empty; for example, this event is sent if the media has already been loaded (or partially loaded), and the <code>load()</code> method is called to reload it.</td>
|
<td>Sent when enough data is available that the media can be played, at least for a couple of frames. This corresponds to the <code>HAVE_ENOUGH_DATA</code> <code>readyState</code>.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>ended</code></td>
|
<td><code>canplaythrough</code></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>Sent when playback completes.</td>
|
<td>Sent when the ready state changes to <code>CAN_PLAY_THROUGH</code>, indicating that the entire media can be played without interruption, assuming the download rate remains at least at the current level. <strong>Note</strong>: Manually setting the <code>currentTime</code> will eventually fire a <code>canplaythrough</code> event in firefox. Other browsers might not fire this event.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>error</code></td>
|
<td><code>emptied</code></td>
|
||||||
<td>✔</td>
|
<td>✔</td>
|
||||||
<td>Sent when an error occurs. The element's <code>error</code> attribute contains more information.</td>
|
<td>The media has become empty; for example, this event is sent if the media has already been loaded (or partially loaded), and the <code>load()</code> method is called to reload it.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>loadeddata</code></td>
|
<td><code>ended</code></td>
|
||||||
<td>✔</td>
|
<td></td>
|
||||||
<td>The first frame of the media has finished loading.</td>
|
<td>Sent when playback completes. Note: with Vimeo this does not occur if `loop` is enabled.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>loadedmetadata</code></td>
|
<td><code>error</code></td>
|
||||||
<td>✔</td>
|
<td>✔</td>
|
||||||
<td>The media's metadata has finished loading; all attributes now contain as much useful information as they're going to.</td>
|
<td>Sent when an error occurs. The element's <code>error</code> attribute contains more information.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>loadstart</code></td>
|
<td><code>loadeddata</code></td>
|
||||||
<td>✔</td>
|
<td>✔</td>
|
||||||
<td>Sent when loading of the media begins.</td>
|
<td>The first frame of the media has finished loading.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>pause</code></td>
|
<td><code>loadedmetadata</code></td>
|
||||||
<td></td>
|
<td>✔</td>
|
||||||
<td>Sent when playback is paused.</td>
|
<td>The media's metadata has finished loading; all attributes now contain as much useful information as they're going to.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>play</code></td>
|
<td><code>loadstart</code></td>
|
||||||
<td></td>
|
<td>✔</td>
|
||||||
<td>Sent when playback of the media starts after having been paused; that is, when playback is resumed after a prior <code>pause</code> event.</td>
|
<td>Sent when loading of the media begins.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>playing</code></td>
|
<td><code>pause</code></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>Sent when the media begins to play (either for the first time, after having been paused, or after ending and then restarting).</td>
|
<td>Sent when playback is paused.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>progress</code></td>
|
<td><code>play</code></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>Sent periodically to inform interested parties of progress downloading the media. Information about the current amount of the media that has been downloaded is available in the media element's <code>buffered</code> attribute.</td>
|
<td>Sent when playback of the media starts after having been paused; that is, when playback is resumed after a prior <code>pause</code> event.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>seeked</code></td>
|
<td><code>playing</code></td>
|
||||||
<td>✔</td>
|
<td></td>
|
||||||
<td>Sent when a seek operation completes.</td>
|
<td>Sent when the media begins to play (either for the first time, after having been paused, or after ending and then restarting).</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>seeking</code></td>
|
<td><code>progress</code></td>
|
||||||
<td>✔</td>
|
<td></td>
|
||||||
<td>Sent when a seek operation begins.</td>
|
<td>Sent periodically to inform interested parties of progress downloading the media. Information about the current amount of the media that has been downloaded is available in the media element's <code>buffered</code> attribute.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>stalled</code></td>
|
<td><code>seeked</code></td>
|
||||||
<td>✔</td>
|
<td></td>
|
||||||
<td>Sent when the user agent is trying to fetch media data, but data is unexpectedly not forthcoming.</td>
|
<td>Sent when a seek operation completes.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>timeupdate</code></td>
|
<td><code>seeking</code></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>The time indicated by the element's <code>currentTime</code> attribute has changed.</td>
|
<td>Sent when a seek operation begins.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>volumechange</code></td>
|
<td><code>stalled</code></td>
|
||||||
<td></td>
|
<td>✔</td>
|
||||||
<td>Sent when the audio volume changes (both when the volume is set and when the <code>muted</code> attribute is changed).</td>
|
<td>Sent when the user agent is trying to fetch media data, but data is unexpectedly not forthcoming.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>waiting</code></td>
|
<td><code>timeupdate</code></td>
|
||||||
<td>✔</td>
|
<td></td>
|
||||||
<td>Sent when the requested operation (such as playback) is delayed pending the completion of another operation (such as a seek).</td>
|
<td>The time indicated by the element's <code>currentTime</code> attribute has changed.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>enterfullscreen</code></td>
|
<td><code>volumechange</code></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>User enters fullscreen (either the proper fullscreen or full-window fallback for older browsers)</td>
|
<td>Sent when the audio volume changes (both when the volume is set and when the <code>muted</code> attribute is changed).</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>exitfullscreen</code></td>
|
<td><code>waiting</code></td>
|
||||||
<td></td>
|
<td>✔</td>
|
||||||
<td>User exits fullscreen</td>
|
<td>Sent when the requested operation (such as playback) is delayed pending the completion of another operation (such as a seek).</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>captionsenabled</code></td>
|
<td><code>enterfullscreen</code></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>Captions toggled on</td>
|
<td>User enters fullscreen (either the proper fullscreen or full-window fallback for older browsers)</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>captionsdisabled</code></td>
|
<td><code>exitfullscreen</code></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>Captions toggled off</td>
|
<td>User exits fullscreen</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>ready</code></td>
|
<td><code>captionsenabled</code></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>Triggered when initial setup is done or a source change has occurred.</td>
|
<td>Captions toggled on</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>captionsdisabled</code></td>
|
||||||
|
<td></td>
|
||||||
|
<td>Captions toggled off</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>destroyed</code></td>
|
||||||
|
<td></td>
|
||||||
|
<td>When an instance is destroyed. The original element that replaced the container will be returned to your handler as the event target.</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
Details borrowed from: [https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Media_events](https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Media_events)
|
Details borrowed from: [https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Media_events](https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Media_events)
|
||||||
|
|
||||||
Here's an example of binding an event listener:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
document.querySelector('.js-plyr').addEventListener('ready', function(event) {
|
|
||||||
var player = event.target.plyr;
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
These events also bubble up the DOM.
|
|
||||||
|
|
||||||
## Embeds
|
## Embeds
|
||||||
YouTube and Vimeo are currently supported and function much like a HTML5 video. Check the relevant documentation sections for any differences.
|
YouTube and Vimeo are currently supported and function much like a HTML5 video. Check the relevant documentation sections for any differences. You don't need to worry about including your own versions of the Vimeo or YouTube JavaScript APIs. Plyr will automatically include them.
|
||||||
|
|
||||||
Plyr references a custom version of the Vimeo Froogaloop API as Vimeo have neglected to maintain the library and there were bugs with their version. You don't need to worry about including your own versions of the Vimeo or YouTube JavaScript APIs.
|
The embed third party API's can be accessed through the `getEmbed()` API method.
|
||||||
|
|
||||||
The native API's can be accessed through the `embed` property of the plyr object. For example:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
document.querySelector('.js-plyr').addEventListener('ready', function(event) {
|
|
||||||
var player = event.target.plyr;
|
|
||||||
|
|
||||||
// YouTube
|
|
||||||
console.log(player.embed.getVideoData());
|
|
||||||
|
|
||||||
// Vimeo
|
|
||||||
console.log(player.embed.api('getColor'));
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
More info on the respective API's here:
|
More info on the respective API's here:
|
||||||
[YouTube API Reference](https://developers.google.com/youtube/js_api_reference)
|
|
||||||
[Vimeo API Reference](https://developer.vimeo.com/player/js-api#reference)
|
- [YouTube API Reference](https://developers.google.com/youtube/js_api_reference)
|
||||||
|
- [Vimeo API Reference](https://github.com/vimeo/player.js)
|
||||||
|
|
||||||
*Please note*: not all API methods may work 100%. Your mileage may vary. It's better to use the universal plyr API where possible.
|
*Please note*: not all API methods may work 100%. Your mileage may vary. It's better to use the universal plyr API where possible.
|
||||||
|
|
||||||
## Streaming
|
## Shortcuts
|
||||||
|
By default, a player will bind the following keyboard shortcuts when it has focus. If you have the `global` option to `true` and there's only one player in the document then the shortcuts will work when any element has focus, apart from an element that requires input.
|
||||||
|
|
||||||
|
<table class="table" width="100%">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th width="25%">Key</th>
|
||||||
|
<th width="25%">Global</th>
|
||||||
|
<th width="50%">Action</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td><code>0</code> to <code>9</code></td>
|
||||||
|
<td>✔</td>
|
||||||
|
<td>Seek from 0 to 90% respectively</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>space</code></td>
|
||||||
|
<td></td>
|
||||||
|
<td>Toggle playback</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>K</code></td>
|
||||||
|
<td>✔</td>
|
||||||
|
<td>Toggle playback</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>←</code></td>
|
||||||
|
<td></td>
|
||||||
|
<td>Seek backward by the <code>seekTime</code> option</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>→</code></td>
|
||||||
|
<td></td>
|
||||||
|
<td>Seek forward by the <code>seekTime</code> option</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>↑</code></td>
|
||||||
|
<td></td>
|
||||||
|
<td>Increase volume</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>↓</code></td>
|
||||||
|
<td></td>
|
||||||
|
<td>Decrease volume</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>M</code></td>
|
||||||
|
<td>✔</td>
|
||||||
|
<td>Toggle mute</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>F</code></td>
|
||||||
|
<td>✔</td>
|
||||||
|
<td>Toggle fullscreen</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>C</code></td>
|
||||||
|
<td>✔</td>
|
||||||
|
<td>Toggle captions</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
## Streaming
|
||||||
Because Plyr is an extension of the standard HTML5 video and audio elements, third party streaming plugins can be used with Plyr. Massive thanks to Matias Russitto ([@russitto](https://github.com/russitto)) for working on this. Here's a few examples:
|
Because Plyr is an extension of the standard HTML5 video and audio elements, third party streaming plugins can be used with Plyr. Massive thanks to Matias Russitto ([@russitto](https://github.com/russitto)) for working on this. Here's a few examples:
|
||||||
|
|
||||||
- Using [hls.js](https://github.com/dailymotion/hls.js) - [Demo](http://codepen.io/sampotts/pen/JKEMqB)
|
- Using [hls.js](https://github.com/dailymotion/hls.js) - [Demo](http://codepen.io/sampotts/pen/JKEMqB)
|
||||||
@ -831,7 +988,7 @@ Because Plyr is an extension of the standard HTML5 video and audio elements, thi
|
|||||||
- Using [dash.js](https://github.com/Dash-Industry-Forum/dash.js) - [Demo](http://codepen.io/sampotts/pen/BzpJXN)
|
- Using [dash.js](https://github.com/Dash-Industry-Forum/dash.js) - [Demo](http://codepen.io/sampotts/pen/BzpJXN)
|
||||||
|
|
||||||
## Fullscreen
|
## Fullscreen
|
||||||
Fullscreen in Plyr is supported by all browsers that [currently support it](http://caniuse.com/#feat=fullscreen). If you're using the default CSS, you can also use a "full browser" mode which will use the full browser window by adding the `plyr-fullscreen` class to your container.
|
Fullscreen in Plyr is supported by all browsers that [currently support it](http://caniuse.com/#feat=fullscreen).
|
||||||
|
|
||||||
## Browser support
|
## Browser support
|
||||||
|
|
||||||
@ -862,7 +1019,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:
|
||||||
|
|
||||||
@ -880,7 +1037,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)
|
||||||
@ -896,6 +1057,11 @@ Plyr is developed by [@sam_potts](https://twitter.com/sam_potts) / [sampotts.me]
|
|||||||
|
|
||||||
## Used by
|
## Used by
|
||||||
- [Selz.com](https://selz.com)
|
- [Selz.com](https://selz.com)
|
||||||
|
- [Peugeot.fr](http://www.peugeot.fr/marque-et-technologie/technologies/peugeot-i-cockpit.html)
|
||||||
|
- [Peugeot.de](http://www.peugeot.de/modelle/modellberater/208-3-turer/fotos-videos.html)
|
||||||
|
- [TomTom.com](http://prioritydriving.tomtom.com/)
|
||||||
|
- [DIGBMX](http://digbmx.com/)
|
||||||
|
- [Grime Archive](https://grimearchive.com/)
|
||||||
- [koel - A personal music streaming server that works.](http://koel.phanan.net/)
|
- [koel - A personal music streaming server that works.](http://koel.phanan.net/)
|
||||||
- [Oscar Radio](http://oscar-radio.xyz/)
|
- [Oscar Radio](http://oscar-radio.xyz/)
|
||||||
|
|
||||||
@ -911,5 +1077,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).
|
||||||
|
3097
src/js/plyr.js
3097
src/js/plyr.js
File diff suppressed because it is too large
Load Diff
@ -9,7 +9,9 @@
|
|||||||
// Animation
|
// Animation
|
||||||
// ---------------------------------------
|
// ---------------------------------------
|
||||||
@keyframes plyr-progress {
|
@keyframes plyr-progress {
|
||||||
to { background-position: @plyr-progress-loading-size 0; }
|
to {
|
||||||
|
background-position: @plyr-progress-loading-size 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Styles
|
// Styles
|
||||||
@ -35,11 +37,19 @@
|
|||||||
|
|
||||||
& when (@plyr-touch-action = true) {
|
& when (@plyr-touch-action = true) {
|
||||||
// Fix 300ms delay
|
// Fix 300ms delay
|
||||||
a, button, input, label {
|
a,
|
||||||
|
button,
|
||||||
|
input,
|
||||||
|
label {
|
||||||
touch-action: manipulation;
|
touch-action: manipulation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Focus
|
||||||
|
&:focus {
|
||||||
|
outline: 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Media elements
|
// Media elements
|
||||||
video,
|
video,
|
||||||
audio {
|
audio {
|
||||||
@ -51,19 +61,19 @@
|
|||||||
|
|
||||||
// Range inputs
|
// Range inputs
|
||||||
// Specificity is for bootstrap compatibility
|
// Specificity is for bootstrap compatibility
|
||||||
input[type='range'] {
|
input[type="range"] {
|
||||||
display: block;
|
display: block;
|
||||||
height: (@plyr-range-thumb-height * @plyr-range-thumb-active-scale);
|
height: (@plyr-range-thumb-height * @plyr-range-thumb-active-scale);
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
|
|
||||||
appearance: none;
|
appearance: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
border: none;
|
border: none;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
|
|
||||||
// WebKit
|
// WebKit
|
||||||
&::-webkit-slider-runnable-track {
|
&::-webkit-slider-runnable-track {
|
||||||
.plyr-range-track();
|
.plyr-range-track();
|
||||||
@ -81,7 +91,7 @@
|
|||||||
&::-moz-range-thumb {
|
&::-moz-range-thumb {
|
||||||
.plyr-range-thumb();
|
.plyr-range-thumb();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Microsoft
|
// Microsoft
|
||||||
&::-ms-track {
|
&::-ms-track {
|
||||||
height: @plyr-range-track-height;
|
height: @plyr-range-track-height;
|
||||||
@ -99,7 +109,7 @@
|
|||||||
&::-ms-thumb {
|
&::-ms-thumb {
|
||||||
.plyr-range-thumb();
|
.plyr-range-thumb();
|
||||||
// For some reason, Edge uses the -webkit margin above
|
// For some reason, Edge uses the -webkit margin above
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
&::-ms-tooltip {
|
&::-ms-tooltip {
|
||||||
display: none;
|
display: none;
|
||||||
@ -111,11 +121,11 @@
|
|||||||
}
|
}
|
||||||
&::-moz-focus-outer {
|
&::-moz-focus-outer {
|
||||||
border: 0;
|
border: 0;
|
||||||
}
|
}
|
||||||
&.tab-focus:focus {
|
&.tab-focus:focus {
|
||||||
outline-offset: 3px;
|
outline-offset: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pressed styles
|
// Pressed styles
|
||||||
&:active {
|
&:active {
|
||||||
&::-webkit-slider-thumb {
|
&::-webkit-slider-thumb {
|
||||||
@ -132,12 +142,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Video range inputs
|
// Video range inputs
|
||||||
.plyr--video input[type='range'].tab-focus:focus {
|
.plyr--video input[type="range"].tab-focus:focus {
|
||||||
outline: 1px dotted fade(@plyr-video-control-color, 50%);
|
outline: 1px dotted fade(@plyr-video-control-color, 50%);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Audio range inputs
|
// Audio range inputs
|
||||||
.plyr--audio input[type='range'].tab-focus:focus {
|
.plyr--audio input[type="range"].tab-focus:focus {
|
||||||
outline: 1px dotted fade(@plyr-audio-control-color, 50%);
|
outline: 1px dotted fade(@plyr-audio-control-color, 50%);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,16 +178,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;
|
||||||
@ -215,7 +226,7 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
padding: (@plyr-control-spacing * 2);
|
padding: (@plyr-control-spacing * 2);
|
||||||
transform: translateY(-(@plyr-control-spacing * 4));
|
transform: translateY(-(@plyr-control-spacing * 4));
|
||||||
transition: transform .3s ease;
|
transition: transform 0.3s ease;
|
||||||
color: @plyr-captions-color;
|
color: @plyr-captions-color;
|
||||||
font-size: @plyr-font-size-captions-base;
|
font-size: @plyr-font-size-captions-base;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
@ -239,12 +250,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
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
@ -256,7 +270,7 @@
|
|||||||
// Playback controls
|
// Playback controls
|
||||||
.plyr__controls {
|
.plyr__controls {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
||||||
@ -289,7 +303,7 @@
|
|||||||
background: transparent;
|
background: transparent;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: background .3s ease, color .3s ease, opacity .3s ease;
|
transition: background 0.3s ease, color 0.3s ease, opacity 0.3s ease;
|
||||||
color: inherit;
|
color: inherit;
|
||||||
|
|
||||||
svg {
|
svg {
|
||||||
@ -320,7 +334,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Hide controls
|
// Hide controls
|
||||||
.plyr--hide-controls .plyr__controls {
|
.plyr--hide-controls .plyr__controls {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
@ -332,12 +346,13 @@
|
|||||||
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;
|
||||||
border-bottom-right-radius: inherit;
|
border-bottom-right-radius: inherit;
|
||||||
color: @plyr-video-control-color;
|
color: @plyr-video-control-color;
|
||||||
transition: opacity .3s ease;
|
transition: opacity 0.3s ease;
|
||||||
|
|
||||||
button {
|
button {
|
||||||
// Hover and tab focus
|
// Hover and tab focus
|
||||||
@ -381,7 +396,7 @@
|
|||||||
border-radius: 100%;
|
border-radius: 100%;
|
||||||
box-shadow: 0 1px 1px fade(#000, 15%);
|
box-shadow: 0 1px 1px fade(#000, 15%);
|
||||||
color: @plyr-video-control-color;
|
color: @plyr-video-control-color;
|
||||||
transition: all .3s ease;
|
transition: all 0.3s ease;
|
||||||
|
|
||||||
svg {
|
svg {
|
||||||
position: relative;
|
position: relative;
|
||||||
@ -408,11 +423,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// States
|
// States
|
||||||
.plyr__controls [data-plyr='pause'],
|
.plyr__controls [data-plyr="pause"],
|
||||||
.plyr--playing .plyr__controls [data-plyr='play'] {
|
.plyr--playing .plyr__controls [data-plyr="play"] {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
.plyr--playing .plyr__controls [data-plyr='pause'] {
|
.plyr--playing .plyr__controls [data-plyr="pause"] {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -428,12 +443,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Some options are hidden by default
|
// Some options are hidden by default
|
||||||
.plyr [data-plyr='captions'],
|
.plyr [data-plyr="captions"],
|
||||||
.plyr [data-plyr='fullscreen'] {
|
.plyr [data-plyr="fullscreen"] {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
.plyr--captions-enabled [data-plyr='captions'],
|
.plyr--captions-enabled [data-plyr="captions"],
|
||||||
.plyr--fullscreen-enabled [data-plyr='fullscreen'] {
|
.plyr--fullscreen-enabled [data-plyr="fullscreen"] {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -455,19 +470,19 @@
|
|||||||
font-size: @plyr-font-size-small;
|
font-size: @plyr-font-size-small;
|
||||||
line-height: 1.3;
|
line-height: 1.3;
|
||||||
|
|
||||||
transform: translate(-50%, 10px) scale(.8);
|
transform: translate(-50%, 10px) scale(0.8);
|
||||||
transform-origin: 50% 100%;
|
transform-origin: 50% 100%;
|
||||||
transition: transform .2s .1s ease, opacity .2s .1s ease;
|
transition: transform 0.2s 0.1s ease, opacity 0.2s 0.1s ease;
|
||||||
|
|
||||||
&::before {
|
&::before {
|
||||||
// Arrows
|
// Arrows
|
||||||
content: '';
|
content: "";
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 0;
|
width: 0;
|
||||||
height: 0;
|
height: 0;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translateX(-50%);
|
transform: translateX(-50%);
|
||||||
|
|
||||||
// The background triangle
|
// The background triangle
|
||||||
bottom: -@plyr-tooltip-arrow-size;
|
bottom: -@plyr-tooltip-arrow-size;
|
||||||
border-right: @plyr-tooltip-arrow-size solid transparent;
|
border-right: @plyr-tooltip-arrow-size solid transparent;
|
||||||
@ -489,7 +504,7 @@
|
|||||||
// First tooltip
|
// First tooltip
|
||||||
.plyr__controls button:first-child .plyr__tooltip {
|
.plyr__controls button:first-child .plyr__tooltip {
|
||||||
left: 0;
|
left: 0;
|
||||||
transform: translate(0, 10px) scale(.8);
|
transform: translate(0, 10px) scale(0.8);
|
||||||
transform-origin: 0 100%;
|
transform-origin: 0 100%;
|
||||||
|
|
||||||
&::before {
|
&::before {
|
||||||
@ -500,7 +515,7 @@
|
|||||||
// Last tooltip
|
// Last tooltip
|
||||||
.plyr__controls button:last-child .plyr__tooltip {
|
.plyr__controls button:last-child .plyr__tooltip {
|
||||||
right: 0;
|
right: 0;
|
||||||
transform: translate(0, 10px) scale(.8);
|
transform: translate(0, 10px) scale(0.8);
|
||||||
transform-origin: 100% 100%;
|
transform-origin: 100% 100%;
|
||||||
|
|
||||||
&::before {
|
&::before {
|
||||||
@ -519,7 +534,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Playback progress
|
// Playback progress
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
// <progress> element
|
// <progress> element
|
||||||
@ -611,20 +625,20 @@
|
|||||||
}
|
}
|
||||||
.plyr__progress--buffer {
|
.plyr__progress--buffer {
|
||||||
&::-webkit-progress-value {
|
&::-webkit-progress-value {
|
||||||
transition: width .2s ease;
|
transition: width 0.2s ease;
|
||||||
}
|
}
|
||||||
&::-moz-progress-bar {
|
&::-moz-progress-bar {
|
||||||
transition: width .2s ease;
|
transition: width 0.2s ease;
|
||||||
}
|
}
|
||||||
&::-ms-fill {
|
&::-ms-fill {
|
||||||
transition: width .2s ease;
|
transition: width 0.2s ease;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.plyr--video .plyr__progress--buffer,
|
.plyr--video .plyr__progress--buffer,
|
||||||
.plyr--video .plyr__volume--display {
|
.plyr--video .plyr__volume--display {
|
||||||
background: @plyr-video-range-track-bg;
|
background: @plyr-video-range-track-bg;
|
||||||
}
|
}
|
||||||
.plyr--video .plyr__progress--buffer {
|
.plyr--video .plyr__progress--buffer {
|
||||||
color: @plyr-video-progress-buffered-bg;
|
color: @plyr-video-progress-buffered-bg;
|
||||||
}
|
}
|
||||||
.plyr--audio .plyr__progress--buffer,
|
.plyr--audio .plyr__progress--buffer,
|
||||||
@ -648,7 +662,8 @@
|
|||||||
@plyr-progress-loading-bg 50%,
|
@plyr-progress-loading-bg 50%,
|
||||||
@plyr-progress-loading-bg 75%,
|
@plyr-progress-loading-bg 75%,
|
||||||
transparent 75%,
|
transparent 75%,
|
||||||
transparent);
|
transparent
|
||||||
|
);
|
||||||
color: transparent;
|
color: transparent;
|
||||||
}
|
}
|
||||||
.plyr--video.plyr--loading .plyr__progress--buffer {
|
.plyr--video.plyr--loading .plyr__progress--buffer {
|
||||||
@ -675,7 +690,7 @@
|
|||||||
|
|
||||||
// Add a slash in before
|
// Add a slash in before
|
||||||
&::before {
|
&::before {
|
||||||
content: '\2044';
|
content: "\2044";
|
||||||
margin-right: @plyr-control-spacing;
|
margin-right: @plyr-control-spacing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -706,24 +721,17 @@
|
|||||||
// It's not supported to change volume using JavaScript:
|
// It's not supported to change volume using JavaScript:
|
||||||
// https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Device-SpecificConsiderations/Device-SpecificConsiderations.html
|
// https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Device-SpecificConsiderations/Device-SpecificConsiderations.html
|
||||||
.plyr--is-ios .plyr__volume,
|
.plyr--is-ios .plyr__volume,
|
||||||
.plyr--is-ios [data-plyr='mute'] {
|
.plyr--is-ios [data-plyr="mute"] {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fullscreen
|
// Fullscreen
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
.plyr--fullscreen,
|
|
||||||
.plyr--fullscreen-active {
|
.plyr--fullscreen-active {
|
||||||
position: fixed;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
bottom: 0;
|
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
z-index: 10000000;
|
|
||||||
background: #000;
|
background: #000;
|
||||||
border-radius: 0;
|
border-radius: 0 !important;
|
||||||
|
|
||||||
video {
|
video {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
@ -732,11 +740,9 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
.plyr__controls {
|
.plyr__video-embed {
|
||||||
position: absolute;
|
// Revert overflow change
|
||||||
bottom: 0;
|
overflow: visible;
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vimeo requires some different styling
|
// Vimeo requires some different styling
|
||||||
@ -746,3 +752,13 @@
|
|||||||
transform: translateY(-50%);
|
transform: translateY(-50%);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fallback for unsupported browsers
|
||||||
|
.plyr--fullscreen-fallback.plyr--fullscreen-active {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
z-index: 10000000;
|
||||||
|
}
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
@plyr-color-main: #3498db;
|
@plyr-color-main: #3498db;
|
||||||
|
|
||||||
// Font
|
// Font
|
||||||
@plyr-font-family: 'San Francisco', -apple-system, BlinkMacSystemFont, '.SFNSText-Regular', Avenir, 'Avenir Next', 'Helvetica Neue', 'Segoe UI', Helvetica, Arial, sans-serif;
|
@plyr-font-family: Avenir, 'Avenir Next', 'Helvetica Neue', 'Segoe UI', Helvetica, Arial, sans-serif;
|
||||||
@plyr-font-size-small: 14px;
|
@plyr-font-size-small: 14px;
|
||||||
@plyr-font-size-base: 16px;
|
@plyr-font-size-base: 16px;
|
||||||
|
|
||||||
@ -68,4 +68,5 @@
|
|||||||
|
|
||||||
// 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;
|
@ -9,7 +9,9 @@
|
|||||||
// Animation
|
// Animation
|
||||||
// ---------------------------------------
|
// ---------------------------------------
|
||||||
@keyframes plyr-progress {
|
@keyframes plyr-progress {
|
||||||
to { background-position: $plyr-progress-loading-size 0; }
|
to {
|
||||||
|
background-position: $plyr-progress-loading-size 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Styles
|
// Styles
|
||||||
@ -34,10 +36,18 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@if $plyr-touch-action == true {
|
@if $plyr-touch-action == true {
|
||||||
// Fix 300ms delay
|
// Fix 300ms delay
|
||||||
a, button, input, label {
|
a,
|
||||||
touch-action: manipulation;
|
button,
|
||||||
}
|
input,
|
||||||
|
label {
|
||||||
|
touch-action: manipulation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Focus
|
||||||
|
&:focus {
|
||||||
|
outline: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Media elements
|
// Media elements
|
||||||
@ -51,19 +61,19 @@
|
|||||||
|
|
||||||
// Range inputs
|
// Range inputs
|
||||||
// Specificity is for bootstrap compatibility
|
// Specificity is for bootstrap compatibility
|
||||||
input[type='range'] {
|
input[type="range"] {
|
||||||
display: block;
|
display: block;
|
||||||
height: ($plyr-range-thumb-height * $plyr-range-thumb-active-scale);
|
height: ($plyr-range-thumb-height * $plyr-range-thumb-active-scale);
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
|
|
||||||
appearance: none;
|
appearance: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
border: none;
|
border: none;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
|
|
||||||
// WebKit
|
// WebKit
|
||||||
&::-webkit-slider-runnable-track {
|
&::-webkit-slider-runnable-track {
|
||||||
@include plyr-range-track();
|
@include plyr-range-track();
|
||||||
@ -81,7 +91,7 @@
|
|||||||
&::-moz-range-thumb {
|
&::-moz-range-thumb {
|
||||||
@include plyr-range-thumb();
|
@include plyr-range-thumb();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Microsoft
|
// Microsoft
|
||||||
&::-ms-track {
|
&::-ms-track {
|
||||||
height: $plyr-range-track-height;
|
height: $plyr-range-track-height;
|
||||||
@ -99,7 +109,7 @@
|
|||||||
&::-ms-thumb {
|
&::-ms-thumb {
|
||||||
@include plyr-range-thumb();
|
@include plyr-range-thumb();
|
||||||
// For some reason, Edge uses the -webkit margin above
|
// For some reason, Edge uses the -webkit margin above
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
&::-ms-tooltip {
|
&::-ms-tooltip {
|
||||||
display: none;
|
display: none;
|
||||||
@ -111,11 +121,11 @@
|
|||||||
}
|
}
|
||||||
&::-moz-focus-outer {
|
&::-moz-focus-outer {
|
||||||
border: 0;
|
border: 0;
|
||||||
}
|
}
|
||||||
&.tab-focus:focus {
|
&.tab-focus:focus {
|
||||||
outline-offset: 3px;
|
outline-offset: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pressed styles
|
// Pressed styles
|
||||||
&:active {
|
&:active {
|
||||||
&::-webkit-slider-thumb {
|
&::-webkit-slider-thumb {
|
||||||
@ -132,13 +142,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Video range inputs
|
// Video range inputs
|
||||||
.plyr--video input[type='range'].tab-focus:focus {
|
.plyr--video input[type="range"].tab-focus:focus {
|
||||||
outline: 1px dotted transparentize($plyr-video-control-color, .5);
|
outline: 1px dotted transparentize($plyr-video-control-color, 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Audio range inputs
|
// Audio range inputs
|
||||||
.plyr--audio input[type='range'].tab-focus:focus {
|
.plyr--audio input[type="range"].tab-focus:focus {
|
||||||
outline: 1px dotted transparentize($plyr-audio-control-color, .5);
|
outline: 1px dotted transparentize($plyr-audio-control-color, 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Screen reader only elements
|
// Screen reader only elements
|
||||||
@ -167,18 +177,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;
|
||||||
@ -215,7 +225,7 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
padding: ($plyr-control-spacing * 2);
|
padding: ($plyr-control-spacing * 2);
|
||||||
transform: translateY(-($plyr-control-spacing * 6));
|
transform: translateY(-($plyr-control-spacing * 6));
|
||||||
transition: transform .3s ease;
|
transition: transform 0.3s ease;
|
||||||
color: $plyr-captions-color;
|
color: $plyr-captions-color;
|
||||||
font-size: $plyr-font-size-captions-base;
|
font-size: $plyr-font-size-captions-base;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
@ -239,12 +249,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
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
@ -256,7 +269,7 @@
|
|||||||
// Playback controls
|
// Playback controls
|
||||||
.plyr__controls {
|
.plyr__controls {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
||||||
@ -284,12 +297,12 @@
|
|||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
overflow: visible; // IE11
|
overflow: visible; // IE11
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
padding: ($plyr-control-spacing * .7);
|
padding: ($plyr-control-spacing * 0.7);
|
||||||
border: 0;
|
border: 0;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: background .3s ease, color .3s ease, opacity .3s ease;
|
transition: background 0.3s ease, color 0.3s ease, opacity 0.3s ease;
|
||||||
color: inherit;
|
color: inherit;
|
||||||
|
|
||||||
svg {
|
svg {
|
||||||
@ -320,7 +333,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Hide controls
|
// Hide controls
|
||||||
.plyr--hide-controls .plyr__controls {
|
.plyr--hide-controls .plyr__controls {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
@ -333,11 +346,14 @@
|
|||||||
right: 0;
|
right: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
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(transparentize($plyr-video-controls-bg, 1), transparentize($plyr-video-controls-bg, .5));
|
background: linear-gradient(
|
||||||
|
transparentize($plyr-video-controls-bg, 1),
|
||||||
|
transparentize($plyr-video-controls-bg, 0.5)
|
||||||
|
);
|
||||||
border-bottom-left-radius: inherit;
|
border-bottom-left-radius: inherit;
|
||||||
border-bottom-right-radius: inherit;
|
border-bottom-right-radius: inherit;
|
||||||
color: $plyr-video-control-color;
|
color: $plyr-video-control-color;
|
||||||
transition: opacity .3s ease;
|
transition: opacity 0.3s ease;
|
||||||
|
|
||||||
button {
|
button {
|
||||||
// Hover and tab focus
|
// Hover and tab focus
|
||||||
@ -379,9 +395,9 @@
|
|||||||
background: $plyr-video-control-bg-hover;
|
background: $plyr-video-control-bg-hover;
|
||||||
border: 4px solid currentColor;
|
border: 4px solid currentColor;
|
||||||
border-radius: 100%;
|
border-radius: 100%;
|
||||||
box-shadow: 0 1px 1px transparentize(#000, .85);
|
box-shadow: 0 1px 1px transparentize(#000, 0.85);
|
||||||
color: $plyr-video-control-color;
|
color: $plyr-video-control-color;
|
||||||
transition: all .3s ease;
|
transition: all 0.3s ease;
|
||||||
|
|
||||||
svg {
|
svg {
|
||||||
position: relative;
|
position: relative;
|
||||||
@ -393,7 +409,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
&:focus {
|
&:focus {
|
||||||
outline: 1px dotted transparentize($plyr-video-control-color, .5);
|
outline: 1px dotted transparentize($plyr-video-control-color, 0.5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.plyr .plyr__play-large {
|
.plyr .plyr__play-large {
|
||||||
@ -408,11 +424,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// States
|
// States
|
||||||
.plyr__controls [data-plyr='pause'],
|
.plyr__controls [data-plyr="pause"],
|
||||||
.plyr--playing .plyr__controls [data-plyr='play'] {
|
.plyr--playing .plyr__controls [data-plyr="play"] {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
.plyr--playing .plyr__controls [data-plyr='pause'] {
|
.plyr--playing .plyr__controls [data-plyr="pause"] {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -428,12 +444,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Some options are hidden by default
|
// Some options are hidden by default
|
||||||
.plyr [data-plyr='captions'],
|
.plyr [data-plyr="captions"],
|
||||||
.plyr [data-plyr='fullscreen'] {
|
.plyr [data-plyr="fullscreen"] {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
.plyr--captions-enabled [data-plyr='captions'],
|
.plyr--captions-enabled [data-plyr="captions"],
|
||||||
.plyr--fullscreen-enabled [data-plyr='fullscreen'] {
|
.plyr--fullscreen-enabled [data-plyr="fullscreen"] {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -455,19 +471,19 @@
|
|||||||
font-size: $plyr-font-size-small;
|
font-size: $plyr-font-size-small;
|
||||||
line-height: 1.3;
|
line-height: 1.3;
|
||||||
|
|
||||||
transform: translate(-50%, 10px) scale(.8);
|
transform: translate(-50%, 10px) scale(0.8);
|
||||||
transform-origin: 50% 100%;
|
transform-origin: 50% 100%;
|
||||||
transition: transform .2s .1s ease, opacity .2s .1s ease;
|
transition: transform 0.2s 0.1s ease, opacity 0.2s 0.1s ease;
|
||||||
|
|
||||||
&::before {
|
&::before {
|
||||||
// Arrows
|
// Arrows
|
||||||
content: '';
|
content: "";
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 0;
|
width: 0;
|
||||||
height: 0;
|
height: 0;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translateX(-50%);
|
transform: translateX(-50%);
|
||||||
|
|
||||||
// The background triangle
|
// The background triangle
|
||||||
bottom: -$plyr-tooltip-arrow-size;
|
bottom: -$plyr-tooltip-arrow-size;
|
||||||
border-right: $plyr-tooltip-arrow-size solid transparent;
|
border-right: $plyr-tooltip-arrow-size solid transparent;
|
||||||
@ -489,7 +505,7 @@
|
|||||||
// First tooltip
|
// First tooltip
|
||||||
.plyr__controls button:first-child .plyr__tooltip {
|
.plyr__controls button:first-child .plyr__tooltip {
|
||||||
left: 0;
|
left: 0;
|
||||||
transform: translate(0, 10px) scale(.8);
|
transform: translate(0, 10px) scale(0.8);
|
||||||
transform-origin: 0 100%;
|
transform-origin: 0 100%;
|
||||||
|
|
||||||
&::before {
|
&::before {
|
||||||
@ -500,7 +516,7 @@
|
|||||||
// Last tooltip
|
// Last tooltip
|
||||||
.plyr__controls button:last-child .plyr__tooltip {
|
.plyr__controls button:last-child .plyr__tooltip {
|
||||||
right: 0;
|
right: 0;
|
||||||
transform: translate(0, 10px) scale(.8);
|
transform: translate(0, 10px) scale(0.8);
|
||||||
transform-origin: 100% 100%;
|
transform-origin: 100% 100%;
|
||||||
|
|
||||||
&::before {
|
&::before {
|
||||||
@ -610,20 +626,20 @@
|
|||||||
}
|
}
|
||||||
.plyr__progress--buffer {
|
.plyr__progress--buffer {
|
||||||
&::-webkit-progress-value {
|
&::-webkit-progress-value {
|
||||||
transition: width .2s ease;
|
transition: width 0.2s ease;
|
||||||
}
|
}
|
||||||
&::-moz-progress-bar {
|
&::-moz-progress-bar {
|
||||||
transition: width .2s ease;
|
transition: width 0.2s ease;
|
||||||
}
|
}
|
||||||
&::-ms-fill {
|
&::-ms-fill {
|
||||||
transition: width .2s ease;
|
transition: width 0.2s ease;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.plyr--video .plyr__progress--buffer,
|
.plyr--video .plyr__progress--buffer,
|
||||||
.plyr--video .plyr__volume--display {
|
.plyr--video .plyr__volume--display {
|
||||||
background: $plyr-video-range-track-bg;
|
background: $plyr-video-range-track-bg;
|
||||||
}
|
}
|
||||||
.plyr--video .plyr__progress--buffer {
|
.plyr--video .plyr__progress--buffer {
|
||||||
color: $plyr-video-progress-buffered-bg;
|
color: $plyr-video-progress-buffered-bg;
|
||||||
}
|
}
|
||||||
.plyr--audio .plyr__progress--buffer,
|
.plyr--audio .plyr__progress--buffer,
|
||||||
@ -647,7 +663,8 @@
|
|||||||
$plyr-progress-loading-bg 50%,
|
$plyr-progress-loading-bg 50%,
|
||||||
$plyr-progress-loading-bg 75%,
|
$plyr-progress-loading-bg 75%,
|
||||||
transparent 75%,
|
transparent 75%,
|
||||||
transparent);
|
transparent
|
||||||
|
);
|
||||||
color: transparent;
|
color: transparent;
|
||||||
}
|
}
|
||||||
.plyr--video.plyr--loading .plyr__progress--buffer {
|
.plyr--video.plyr--loading .plyr__progress--buffer {
|
||||||
@ -674,7 +691,7 @@
|
|||||||
|
|
||||||
// Add a slash in before
|
// Add a slash in before
|
||||||
&::before {
|
&::before {
|
||||||
content: '\2044';
|
content: "\2044";
|
||||||
margin-right: $plyr-control-spacing;
|
margin-right: $plyr-control-spacing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -705,24 +722,17 @@
|
|||||||
// It's not supported to change volume using JavaScript:
|
// It's not supported to change volume using JavaScript:
|
||||||
// https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Device-SpecificConsiderations/Device-SpecificConsiderations.html
|
// https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Device-SpecificConsiderations/Device-SpecificConsiderations.html
|
||||||
.plyr--is-ios .plyr__volume,
|
.plyr--is-ios .plyr__volume,
|
||||||
.plyr--is-ios [data-plyr='mute'] {
|
.plyr--is-ios [data-plyr="mute"] {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fullscreen
|
// Fullscreen
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
.plyr--fullscreen,
|
|
||||||
.plyr--fullscreen-active {
|
.plyr--fullscreen-active {
|
||||||
position: fixed;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
bottom: 0;
|
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
z-index: 10000000;
|
|
||||||
background: #000;
|
background: #000;
|
||||||
border-radius: 0;
|
border-radius: 0 !important;
|
||||||
|
|
||||||
video {
|
video {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
@ -731,11 +741,9 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
.plyr__controls {
|
.plyr__video-embed {
|
||||||
position: absolute;
|
// Revert overflow change
|
||||||
bottom: 0;
|
overflow: visible;
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vimeo requires some different styling
|
// Vimeo requires some different styling
|
||||||
@ -745,3 +753,13 @@
|
|||||||
transform: translateY(-50%);
|
transform: translateY(-50%);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fallback for unsupported browsers
|
||||||
|
.plyr--fullscreen-fallback.plyr--fullscreen-active {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
z-index: 10000000;
|
||||||
|
}
|
||||||
|
@ -13,7 +13,7 @@ $plyr-sr-only-important: true !default;
|
|||||||
$plyr-color-main: #3498db !default;
|
$plyr-color-main: #3498db !default;
|
||||||
|
|
||||||
// Font sizes
|
// Font sizes
|
||||||
$plyr-font-family: 'San Francisco', -apple-system, BlinkMacSystemFont, '.SFNSText-Regular', Avenir, 'Avenir Next', 'Helvetica Neue', 'Segoe UI', Helvetica, Arial, sans-serif;
|
$plyr-font-family: Avenir, 'Avenir Next', 'Helvetica Neue', 'Segoe UI', Helvetica, Arial, sans-serif !default;
|
||||||
$plyr-font-size-small: 14px !default;
|
$plyr-font-size-small: 14px !default;
|
||||||
$plyr-font-size-base: 16px !default;
|
$plyr-font-size-base: 16px !default;
|
||||||
|
|
||||||
@ -69,4 +69,5 @@ $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