Merge branch 'master' into develop
# Conflicts: # src/js/plyr.js
10
bundles.json
@ -10,14 +10,14 @@
|
|||||||
"plyr.js": ["src/js/plyr.js"]
|
"plyr.js": ["src/js/plyr.js"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"docs": {
|
"demo": {
|
||||||
"less": {
|
"less": {
|
||||||
"docs.css": ["docs/src/less/docs.less"]
|
"demo.css": ["demo/src/less/demo.less"]
|
||||||
},
|
},
|
||||||
"js": {
|
"js": {
|
||||||
"docs.js": [
|
"demo.js": [
|
||||||
"docs/src/js/lib/classlist.js",
|
"demo/src/js/lib/classlist.js",
|
||||||
"docs/src/js/docs.js"
|
"demo/src/js/main.js"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
132
changelog.md
@ -1,5 +1,97 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 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
|
||||||
|
- Fix for seek issues introduced in v1.8.9
|
||||||
|
|
||||||
|
## v1.8.9
|
||||||
|
- Fix for fullscreen not being defined (Fixes #295)
|
||||||
|
- Fix for multiline captions (Fixes #314)
|
||||||
|
- Clean up of type checks and fix for `restart()` (Fixes #315)
|
||||||
|
- Fix for `MEDIA_ERR_SRC_NOT_SUPPORTED` when calling `.source()` API method
|
||||||
|
|
||||||
|
## v1.8.8
|
||||||
|
- Added getCurrentTime API method (fixes #292)
|
||||||
|
- Fix for !hideControls on touch devices (fixes #303)
|
||||||
|
|
||||||
|
## v1.8.7
|
||||||
|
- Line height fix
|
||||||
|
|
||||||
|
## v1.8.6
|
||||||
|
- Reverted font size change
|
||||||
|
|
||||||
|
## v1.8.5
|
||||||
|
- Fixed overflow issues (fixes #286)
|
||||||
|
|
||||||
|
## v1.8.4
|
||||||
|
- Fix for large play button on small videos
|
||||||
|
|
||||||
|
## v1.8.3
|
||||||
|
- Disabled iPad support for YouTube and Vimeo due to iOS limitations with iFrame playback
|
||||||
|
- Fixed IE11 icon loading (fixes #269)
|
||||||
|
- Updated screenshot (fixes #281)
|
||||||
|
- Added WordPress plugin (fixes #239)
|
||||||
|
- Added Neos plugin
|
||||||
|
- Added HLS, Shaka and dash.js examples (see #235 for more)
|
||||||
|
- Improvements for controls hiding and showing on touch devices
|
||||||
|
|
||||||
|
## v1.8.2
|
||||||
|
- Fixed event bubbling
|
||||||
|
|
||||||
|
## v1.8.1
|
||||||
|
- Fixed inaccurate log message
|
||||||
|
|
||||||
|
# v1.8.0
|
||||||
|
- ***(Important)*** `setup()` now returns the element Plyr was setup on rather than the `plyr` object. This means `var player = plyr.setup()[0];` would now be `var player = plyr.setup()[0].plyr;`. This improves support for React and other virtual dom frameworks as mentioned in #254
|
||||||
|
- Fixed using a relative URL for `iconUrl` in IE (fixes #269)
|
||||||
|
|
||||||
|
# v1.7.0
|
||||||
|
- SASS cleanup (fixes #265)
|
||||||
|
- Docs tidy up to help quick start (fixes #253)
|
||||||
|
- Fix for issues with data attribute options passing (fixes #257)
|
||||||
|
- ***(Important)*** Removed the requirement for a wrapper div to setup Plyr and removed the dependency on the `plyr` classname as a JS hook. By default it will now look for `<video>`, `<audio>` and `[data-type]` elements. If you are just calling `setup()` with a `<div class="plyr">` you may want to give it a good test after upgrading. You can probably remove the wrapper div. The reason behind this is to make setup easier for newcomers and prevent the styling being used on unsupported players (because the plyr classname was used as a CSS and JS hook - which isn't ideal)
|
||||||
|
- Renamed the 'docs' folder to `demo` to avoid confusion - the readme is the docs after all
|
||||||
|
|
||||||
|
## v1.6.20
|
||||||
|
- Fix for multiple sprites being requested (fixes #259)
|
||||||
|
|
||||||
|
## v1.6.19
|
||||||
|
- Fix for scroll direction issues on volume control (fixes #258)
|
||||||
|
|
||||||
|
## v1.6.18
|
||||||
|
- Reduced rounding of seek value from 1 decimal point to 4 (fixes #242)
|
||||||
|
|
||||||
|
## v1.6.17
|
||||||
|
- Added `disableContextMenu` option to hide the right click context menu (fixes #248 and #225)
|
||||||
|
|
||||||
|
## v1.6.16
|
||||||
|
- Always hide standard controls (fixes #225)
|
||||||
|
- Fix for Tooltips overflowing (fixes #230)
|
||||||
|
|
||||||
|
## v1.6.15
|
||||||
|
- Restore scroll position when exiting full screen (fixes #236)
|
||||||
|
|
||||||
|
## v1.6.14
|
||||||
|
- SVG sprite loading automatically for an easier setup
|
||||||
|
- Touch devices now show controls on touch rather than pausing playback
|
||||||
|
|
||||||
|
## v1.6.13
|
||||||
|
- Decreased sensitivity and inverted scroll on volume slider (scroll up to increase, down to decrease)
|
||||||
|
|
||||||
|
## v1.6.12
|
||||||
|
- Fix for undefined buffer error
|
||||||
|
- Add scroll listener on volume slider (PR #227 bty @igoradamenko)
|
||||||
|
|
||||||
## v1.6.11
|
## v1.6.11
|
||||||
- Fix for Vimeo fullscreen (fixes #214)
|
- Fix for Vimeo fullscreen (fixes #214)
|
||||||
|
|
||||||
@ -71,18 +163,18 @@
|
|||||||
- Docs fixes inc controls HTML (fixes #180)
|
- Docs fixes inc controls HTML (fixes #180)
|
||||||
|
|
||||||
## v1.5.17
|
## v1.5.17
|
||||||
- Expose YouTube and Vimeo API (docs update required) (Fixes #176)
|
- Expose YouTube and Vimeo API (docs update required) (fixes #176)
|
||||||
- Auto set title based on YouTube getVideoData() title property
|
- Auto set title based on YouTube getVideoData() title property
|
||||||
- Bug fix for Vimeo API change (Uncaught TypeError: Cannot read property 'value' of undefined) due to a change their end
|
- Bug fix for Vimeo API change (Uncaught TypeError: Cannot read property 'value' of undefined) due to a change their end
|
||||||
|
|
||||||
## v1.5.16
|
## v1.5.16
|
||||||
- Cancel requests on source change (Fixes #174)
|
- Cancel requests on source change (fixes #174)
|
||||||
|
|
||||||
## v1.5.15
|
## v1.5.15
|
||||||
- Fix for CustomEvent polyfill and related bug (See #172)
|
- Fix for CustomEvent polyfill and related bug (see #172)
|
||||||
|
|
||||||
## v1.5.14
|
## v1.5.14
|
||||||
- Volume storage fix (Fixes #171)
|
- Volume storage fix (fixes #171)
|
||||||
|
|
||||||
## v1.5.13
|
## v1.5.13
|
||||||
- Fix for manual caption rendering
|
- Fix for manual caption rendering
|
||||||
@ -185,11 +277,11 @@
|
|||||||
## v1.2.3
|
## v1.2.3
|
||||||
- Fix for YouTube on iPhone or unsupported browsers (fallback to YouTube native)
|
- Fix for YouTube on iPhone or unsupported browsers (fallback to YouTube native)
|
||||||
- Docs tidy up
|
- Docs tidy up
|
||||||
- Fullscreen for Safari fix (Fixes #96)
|
- Fullscreen for Safari fix (fixes #96)
|
||||||
|
|
||||||
## v1.2.2
|
## v1.2.2
|
||||||
- Fix for :focus keyboard vs mouse (Fixes #61)
|
- Fix for :focus keyboard vs mouse (fixes #61)
|
||||||
- Fix for caption positioning in full screen (Fixes #92)
|
- Fix for caption positioning in full screen (fixes #92)
|
||||||
|
|
||||||
## v1.2.1
|
## v1.2.1
|
||||||
- Tooltip bug fix
|
- Tooltip bug fix
|
||||||
@ -216,7 +308,7 @@
|
|||||||
- Bug fix for 1.1.8
|
- Bug fix for 1.1.8
|
||||||
|
|
||||||
## v1.1.8
|
## v1.1.8
|
||||||
- setVolume API method improvements (Fixes #83)
|
- setVolume API method improvements (fixes #83)
|
||||||
|
|
||||||
## v1.1.7
|
## v1.1.7
|
||||||
- Restore classname on destroy()
|
- Restore classname on destroy()
|
||||||
@ -225,7 +317,7 @@
|
|||||||
- New API methods (fixes #77), Fix for non strict mode (fixes #78)
|
- New API methods (fixes #77), Fix for non strict mode (fixes #78)
|
||||||
|
|
||||||
## v1.1.5
|
## v1.1.5
|
||||||
- Fix for incorrect `isFullscreen()` return value in Mozilla (Fixes #38)
|
- Fix for incorrect `isFullscreen()` return value in Mozilla (fixes #38)
|
||||||
|
|
||||||
## v1.1.4
|
## v1.1.4
|
||||||
- Minor bug fixes
|
- Minor bug fixes
|
||||||
@ -249,17 +341,17 @@
|
|||||||
- Display duration on `metadataloaded`
|
- Display duration on `metadataloaded`
|
||||||
|
|
||||||
## v1.0.30
|
## v1.0.30
|
||||||
- Fixed bug with media longer than 60 minutes (Fixes #69)
|
- Fixed bug with media longer than 60 minutes (fixes #69)
|
||||||
|
|
||||||
## v1.0.29
|
## v1.0.29
|
||||||
- Added option to hide controls on fullscreen (default `true`) while palying, after 1s. Pause, mouse hover on progress, or focus on a child control re-shows the controls. On touch a tap of the video (which plays/pauses the video by default) is required. (Fixes #47)
|
- Added option to hide controls on fullscreen (default `true`) while palying, after 1s. Pause, mouse hover on progress, or focus on a child control re-shows the controls. On touch a tap of the video (which plays/pauses the video by default) is required. (fixes #47)
|
||||||
- Fixed a bug with caption toggle in 1.0.28
|
- Fixed a bug with caption toggle in 1.0.28
|
||||||
|
|
||||||
## v1.0.28
|
## v1.0.28
|
||||||
- Added API support for browsers that don't have full plyr support (pretty much <=IE9 and `<video>` on iPhone/iPod)
|
- Added API support for browsers that don't have full plyr support (pretty much <=IE9 and `<video>` on iPhone/iPod)
|
||||||
|
|
||||||
## v1.0.27
|
## v1.0.27
|
||||||
- Keyboard accessibility improvements (Fixes #66)
|
- Keyboard accessibility improvements (fixes #66)
|
||||||
|
|
||||||
## v1.0.26
|
## v1.0.26
|
||||||
- Fixes for SASS (cheers @brunowego)
|
- Fixes for SASS (cheers @brunowego)
|
||||||
@ -270,29 +362,29 @@
|
|||||||
- Classnames for left/right controls changed
|
- Classnames for left/right controls changed
|
||||||
|
|
||||||
## v1.0.24
|
## v1.0.24
|
||||||
- Added tooltip option to display labels as tooltips (Fixes #50)
|
- Added tooltip option to display labels as tooltips (fixes #50)
|
||||||
|
|
||||||
## v1.0.23
|
## v1.0.23
|
||||||
- Handling loading states in the UI (Fixes #36)
|
- Handling loading states in the UI (fixes #36)
|
||||||
|
|
||||||
## v1.0.22
|
## v1.0.22
|
||||||
- Added support() API method for checking mimetype support
|
- Added support() API method for checking mimetype support
|
||||||
- Added source() API method for setting media source(s) (Fixes #44)
|
- Added source() API method for setting media source(s) (fixes #44)
|
||||||
- Added poster() API method for setting poster source
|
- Added poster() API method for setting poster source
|
||||||
- Refactored captions logic for manual captions
|
- Refactored captions logic for manual captions
|
||||||
|
|
||||||
## v1.0.21
|
## v1.0.21
|
||||||
- Added an <input type="range"> for seeking to improve experience (and support dragging) (Fixes #40, #42)
|
- Added an <input type="range"> for seeking to improve experience (and support dragging) (fixes #40, #42)
|
||||||
- Icons for restart and captions improved (and some IDs changed) (Fixes #49)
|
- Icons for restart and captions improved (and some IDs changed) (fixes #49)
|
||||||
|
|
||||||
## v1.0.20
|
## v1.0.20
|
||||||
- Default controls included (Fixes #45)
|
- Default controls included (Fixes #45)
|
||||||
- Volume changes on `input` as well as `change` (Fixes #43)
|
- Volume changes on `input` as well as `change` (fixes #43)
|
||||||
- Fix for undefined Play text
|
- Fix for undefined Play text
|
||||||
- License changed to MIT
|
- License changed to MIT
|
||||||
|
|
||||||
## v1.0.19
|
## v1.0.19
|
||||||
- Fixed firefox fullscreen issue (Fixes #38)
|
- Fixed firefox fullscreen issue (fixes #38)
|
||||||
|
|
||||||
## v1.0.18
|
## v1.0.18
|
||||||
- Added CDN references
|
- Added CDN references
|
||||||
@ -316,7 +408,7 @@
|
|||||||
- Minor tweaks
|
- Minor tweaks
|
||||||
|
|
||||||
## v1.0.12
|
## v1.0.12
|
||||||
- Handle native events (Issue #34)
|
- Handle native events (issue #34)
|
||||||
|
|
||||||
## v1.0.11
|
## v1.0.11
|
||||||
- Bug fixes for fullscreen mode
|
- Bug fixes for fullscreen mode
|
||||||
|
1
demo/dist/demo.css
vendored
Normal file
1
demo/dist/demo.js
vendored
Normal file
@ -0,0 +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"));
|
0
docs/dist/docs.svg → demo/dist/demo.svg
vendored
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
@ -11,7 +11,7 @@
|
|||||||
<link rel="stylesheet" href="../dist/plyr.css">
|
<link rel="stylesheet" href="../dist/plyr.css">
|
||||||
|
|
||||||
<!-- Docs styles -->
|
<!-- Docs styles -->
|
||||||
<link rel="stylesheet" href="dist/docs.css">
|
<link rel="stylesheet" href="dist/demo.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
@ -51,7 +51,6 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
<section>
|
<section>
|
||||||
<div class="js-media-player">
|
|
||||||
<video poster="https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.jpg" controls crossorigin>
|
<video poster="https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.jpg" controls crossorigin>
|
||||||
<!-- Video files -->
|
<!-- Video files -->
|
||||||
<source src="https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.mp4" type="video/mp4">
|
<source src="https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.mp4" type="video/mp4">
|
||||||
@ -61,9 +60,8 @@
|
|||||||
<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>
|
<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>
|
||||||
|
|
||||||
<!-- Fallback for browsers that don't support the <video> element -->
|
<!-- Fallback for browsers that don't support the <video> element -->
|
||||||
<a href="https://cdn.selz.com/plyr/1.0/movie.mp4">Download</a>
|
<a href="https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.mp4" download>Download</a>
|
||||||
</video>
|
</video>
|
||||||
</div>
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li class="plyr__cite plyr__cite--video"><small><a href="http://viewfromabluemoon.com/" target="_blank">View From A Blue Moon</a> © Brainfarm</small></li>
|
<li class="plyr__cite plyr__cite--video"><small><a href="http://viewfromabluemoon.com/" target="_blank">View From A Blue Moon</a> © Brainfarm</small></li>
|
||||||
@ -74,55 +72,14 @@
|
|||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<!-- Load SVG defs -->
|
|
||||||
<!-- You should bundle all SVG/Icons into one file using a build tool such as gulp and svg store -->
|
|
||||||
<script>
|
|
||||||
(function() {
|
|
||||||
[
|
|
||||||
'../dist/plyr.svg',
|
|
||||||
'dist/docs.svg'
|
|
||||||
]
|
|
||||||
.forEach(function(u) {
|
|
||||||
var x = new XMLHttpRequest(),
|
|
||||||
b = document.body;
|
|
||||||
|
|
||||||
// Check for CORS support
|
|
||||||
// If you're loading from same domain, you can remove the whole if/else statement
|
|
||||||
// XHR for Chrome/Firefox/Opera/Safari/IE10+
|
|
||||||
if ('withCredentials' in x) {
|
|
||||||
x.open('GET', u, true);
|
|
||||||
}
|
|
||||||
// XDomainRequest for IE8 & IE9
|
|
||||||
else if (typeof XDomainRequest == 'function') {
|
|
||||||
x = new XDomainRequest();
|
|
||||||
x.open('GET', u);
|
|
||||||
}
|
|
||||||
else { return; }
|
|
||||||
|
|
||||||
// Inject hidden div with sprite on load
|
|
||||||
x.onload = function() {
|
|
||||||
var c = document.createElement('div');
|
|
||||||
c.setAttribute('hidden', '');
|
|
||||||
c.innerHTML = x.responseText;
|
|
||||||
b.insertBefore(c, b.childNodes[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Timeout for IE9
|
|
||||||
setTimeout(function () {
|
|
||||||
x.send();
|
|
||||||
}, 0);
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<!-- Plyr core script -->
|
<!-- Plyr core script -->
|
||||||
<script src="../dist/plyr.js"></script>
|
<script src="../dist/plyr.js"></script>
|
||||||
|
|
||||||
<!-- Docs script -->
|
<!-- Docs script -->
|
||||||
<script src="dist/docs.js"></script>
|
<script src="dist/demo.js"></script>
|
||||||
|
|
||||||
<!-- Rangetouch to fix <input type="range"> on touch devices (see https://rangetouch.com) -->
|
<!-- Rangetouch to fix <input type="range"> on touch devices (see https://rangetouch.com) -->
|
||||||
<script src="https://cdn.rangetouch.com/0.0.9/rangetouch.js"></script>
|
<script src="https://cdn.rangetouch.com/0.0.9/rangetouch.js" async></script>
|
||||||
|
|
||||||
<!-- Sharing libary (https://shr.one) -->
|
<!-- Sharing libary (https://shr.one) -->
|
||||||
<script src="https://cdn.shr.one/0.1.9/shr.js"></script>
|
<script src="https://cdn.shr.one/0.1.9/shr.js"></script>
|
185
demo/src/js/main.js
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Plyr.io demo
|
||||||
|
// This code is purely for the plyr.io website
|
||||||
|
// Please see readme.md in the root or github.com/selz/plyr
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
/*global plyr*/
|
||||||
|
|
||||||
|
// General functions
|
||||||
|
;(function() {
|
||||||
|
document.body.addEventListener('ready', function(event) { console.log(event); });
|
||||||
|
|
||||||
|
// Setup the player
|
||||||
|
var instances = plyr.setup({
|
||||||
|
debug: true,
|
||||||
|
title: 'Video demo',
|
||||||
|
iconUrl: '../dist/plyr.svg',
|
||||||
|
tooltips: {
|
||||||
|
controls: true
|
||||||
|
},
|
||||||
|
captions: {
|
||||||
|
defaultActive: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
plyr.loadSprite('dist/demo.svg');
|
||||||
|
|
||||||
|
// Plyr returns an array regardless
|
||||||
|
var player = instances[0].plyr;
|
||||||
|
|
||||||
|
// Setup type toggle
|
||||||
|
var buttons = document.querySelectorAll('[data-source]'),
|
||||||
|
types = {
|
||||||
|
video: 'video',
|
||||||
|
audio: 'audio',
|
||||||
|
youtube: 'youtube',
|
||||||
|
vimeo: 'vimeo'
|
||||||
|
},
|
||||||
|
currentType = window.location.hash.replace('#', ''),
|
||||||
|
historySupport = (window.history && window.history.pushState);
|
||||||
|
|
||||||
|
// Bind to each button
|
||||||
|
for (var i = buttons.length - 1; i >= 0; i--) {
|
||||||
|
buttons[i].addEventListener('click', function() {
|
||||||
|
var type = this.getAttribute('data-source');
|
||||||
|
|
||||||
|
newSource(type);
|
||||||
|
|
||||||
|
if (historySupport) {
|
||||||
|
history.pushState({ 'type': type }, '', '#' + type);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// List for backwards/forwards
|
||||||
|
window.addEventListener('popstate', function(event) {
|
||||||
|
if(event.state && 'type' in event.state) {
|
||||||
|
newSource(event.state.type);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// On load
|
||||||
|
if(historySupport) {
|
||||||
|
var video = !currentType.length;
|
||||||
|
|
||||||
|
// If there's no current type set, assume video
|
||||||
|
if(video) {
|
||||||
|
currentType = types.video;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Replace current history state
|
||||||
|
if(currentType in types) {
|
||||||
|
history.replaceState({ 'type': currentType }, '', (video ? '' : '#' + currentType));
|
||||||
|
}
|
||||||
|
|
||||||
|
// If it's not video, load the source
|
||||||
|
if(currentType !== types.video) {
|
||||||
|
newSource(currentType, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Toggle class on an element
|
||||||
|
function toggleClass(element, className, state) {
|
||||||
|
if (element) {
|
||||||
|
if (element.classList) {
|
||||||
|
element.classList[state ? 'add' : 'remove'](className);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var name = (' ' + element.className + ' ').replace(/\s+/g, ' ').replace(' ' + className + ' ', '');
|
||||||
|
element.className = name + (state ? ' ' + className : '');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set a new source
|
||||||
|
function newSource(type, init) {
|
||||||
|
// Bail if new type isn't known, it's the current type, or current type is empty (video is default) and new type is video
|
||||||
|
if(!(type in types) || (!init && type == currentType) || (!currentType.length && type == types.video)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(type) {
|
||||||
|
case types.video:
|
||||||
|
player.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: true
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case types.audio:
|
||||||
|
player.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 types.youtube:
|
||||||
|
player.source({
|
||||||
|
type: 'video',
|
||||||
|
title: 'View From A Blue Moon',
|
||||||
|
sources: [{
|
||||||
|
src: 'bTqVqk7FSmY',
|
||||||
|
type: 'youtube'
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case types.vimeo:
|
||||||
|
player.source({
|
||||||
|
type: 'video',
|
||||||
|
title: 'View From A Blue Moon',
|
||||||
|
sources: [{
|
||||||
|
src: '143418951',
|
||||||
|
type: 'vimeo'
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the current type for next time
|
||||||
|
currentType = type;
|
||||||
|
|
||||||
|
// Remove active classes
|
||||||
|
for (var x = buttons.length - 1; x >= 0; x--) {
|
||||||
|
toggleClass(buttons[x].parentElement, 'active', false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set active on parent
|
||||||
|
toggleClass(document.querySelector('[data-source="'+ type +'"]').parentElement, 'active', true);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
|
// Google analytics
|
||||||
|
// For demo site (http://[www.]plyr.io) only
|
||||||
|
if(document.domain.indexOf('plyr.io') > -1) {
|
||||||
|
(function(i,s,o,g,r,a,m){i.GoogleAnalyticsObject=r;i[r]=i[r]||function(){
|
||||||
|
(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');
|
||||||
|
}
|
@ -21,7 +21,7 @@ video {
|
|||||||
.plyr--audio {
|
.plyr--audio {
|
||||||
max-width: @example-width-audio;
|
max-width: @example-width-audio;
|
||||||
}
|
}
|
||||||
.plyr--video::after {
|
.plyr__video-wrapper::after {
|
||||||
content: "";
|
content: "";
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
position: absolute;
|
position: absolute;
|
@ -1,5 +1,5 @@
|
|||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
// HTML5 Video Player Demo Page
|
// Plyr.io Demo Page
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
|
||||||
// CSS Reset
|
// CSS Reset
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 981 B After Width: | Height: | Size: 981 B |
Before Width: | Height: | Size: 779 B After Width: | Height: | Size: 779 B |
Before Width: | Height: | Size: 739 B After Width: | Height: | Size: 739 B |
2
dist/plyr.css
vendored
4
dist/plyr.js
vendored
1
docs/dist/docs.css
vendored
1
docs/dist/docs.js
vendored
@ -1 +0,0 @@
|
|||||||
"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,n=arguments.length;for(i=0;n>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",n=e.Element[i],o=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+/):[],n=0,o=i.length;o>n;n++)this.push(i[n]);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,n=t.length,o=!1;do e=t[i]+"",-1===c(this,e)&&(this.push(e),o=!0);while(++i<n);o&&this._updateClassName()},u.remove=function(){var e,t,i=arguments,n=0,o=i.length,s=!1;do for(e=i[n]+"",t=c(this,e);-1!==t;)this.splice(t,1),s=!0,t=c(this,e);while(++n<o);s&&this._updateClassName()},u.toggle=function(e,t){e+="";var i=this.contains(e),n=i?t!==!0&&"remove":t!==!1&&"add";return n&&this[n](e),t===!0||t===!1?t:!i},u.toString=function(){return this.join(" ")},o.defineProperty){var p={get:d,enumerable:!0,configurable:!0};try{o.defineProperty(n,t,p)}catch(h){-2146823252===h.number&&(p.enumerable=!1,o.defineProperty(n,t,p))}}else o[i].__defineGetter__&&n.__defineGetter__(t,d)}}(self)),plyr.setup(".js-media-player",{debug:!0,title:"Video demo",tooltips:{controls:!0},captions:{defaultActive:!0}}),function(){function e(e,t,i){if(e)if(e.classList)e.classList[i?"add":"remove"](t);else{var n=(" "+e.className+" ").replace(/\s+/g," ").replace(" "+t+" ","");e.className=n+(i?" "+t:"")}}function t(t,s){if(t in n&&(s||t!=o)&&(o.length||t!=n.video)){var r=document.querySelector(".js-media-player").plyr;switch(t){case n.video:r.source({type:"video",title:"View From A Blue Moon",sources:[{src:"https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.mp4",type:"video/mp4"},{src:"https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.webm",type:"video/webm"}],poster:"https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.jpg",tracks:[{kind:"captions",label:"English",srclang:"en",src:"https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.en.vtt","default":!0}]});break;case n.audio:r.source({type:"audio",title:"Kishi Bashi – “It All Began With A Burst”",sources:[{src:"https://cdn.selz.com/plyr/1.5/Kishi_Bashi_-_It_All_Began_With_a_Burst.mp3",type:"audio/mp3"},{src:"https://cdn.selz.com/plyr/1.5/Kishi_Bashi_-_It_All_Began_With_a_Burst.ogg",type:"audio/ogg"}]});break;case n.youtube:r.source({type:"video",title:"View From A Blue Moon",sources:[{src:"bTqVqk7FSmY",type:"youtube"}]});break;case n.vimeo:r.source({type:"video",title:"View From A Blue Moon",sources:[{src:"143418951",type:"vimeo"}]})}o=t;for(var a=i.length-1;a>=0;a--)e(i[a].parentElement,"active",!1);e(document.querySelector('[data-source="'+t+'"]').parentElement,"active",!0)}}for(var i=document.querySelectorAll("[data-source]"),n={video:"video",audio:"audio",youtube:"youtube",vimeo:"vimeo"},o=window.location.hash.replace("#",""),s=window.history&&window.history.pushState,r=i.length-1;r>=0;r--)i[r].addEventListener("click",function(){var e=this.getAttribute("data-source");t(e),s&&history.pushState({type:e},"","#"+e)});if(window.addEventListener("popstate",function(e){e.state&&"type"in e.state&&t(e.state.type)}),s){var a=!o.length;a&&(o=n.video),o in n&&history.replaceState({type:o},"",a?"":"#"+o),o!==n.video&&t(o,!0)}}(),document.domain.indexOf("plyr.io")>-1&&(!function(e,t,i,n,o,s,r){e.GoogleAnalyticsObject=o,e[o]=e[o]||function(){(e[o].q=e[o].q||[]).push(arguments)},e[o].l=1*new Date,s=t.createElement(i),r=t.getElementsByTagName(i)[0],s.async=1,s.src=n,r.parentNode.insertBefore(s,r)}(window,document,"script","//www.google-analytics.com/analytics.js","ga"),ga("create","UA-40881672-11","auto"),ga("send","pageview"));
|
|
@ -1,178 +0,0 @@
|
|||||||
// ==========================================================================
|
|
||||||
// Docs example
|
|
||||||
// ==========================================================================
|
|
||||||
|
|
||||||
/*global plyr*/
|
|
||||||
|
|
||||||
// Setup the player
|
|
||||||
plyr.setup('.js-media-player', {
|
|
||||||
debug: true,
|
|
||||||
title: 'Video demo',
|
|
||||||
tooltips: {
|
|
||||||
controls: true
|
|
||||||
},
|
|
||||||
captions: {
|
|
||||||
defaultActive: true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// General functions
|
|
||||||
(function() {
|
|
||||||
var buttons = document.querySelectorAll('[data-source]'),
|
|
||||||
types = {
|
|
||||||
video: 'video',
|
|
||||||
audio: 'audio',
|
|
||||||
youtube: 'youtube',
|
|
||||||
vimeo: 'vimeo'
|
|
||||||
},
|
|
||||||
currentType = window.location.hash.replace('#', ''),
|
|
||||||
historySupport = (window.history && window.history.pushState);
|
|
||||||
|
|
||||||
// Bind to each button
|
|
||||||
for (var i = buttons.length - 1; i >= 0; i--) {
|
|
||||||
buttons[i].addEventListener('click', function() {
|
|
||||||
var type = this.getAttribute('data-source');
|
|
||||||
|
|
||||||
newSource(type);
|
|
||||||
|
|
||||||
if (historySupport) {
|
|
||||||
history.pushState({ 'type': type }, '', '#' + type);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// List for backwards/forwards
|
|
||||||
window.addEventListener('popstate', function(event) {
|
|
||||||
if(event.state && 'type' in event.state) {
|
|
||||||
newSource(event.state.type);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// On load
|
|
||||||
if(historySupport) {
|
|
||||||
var video = !currentType.length;
|
|
||||||
|
|
||||||
// If there's no current type set, assume video
|
|
||||||
if(video) {
|
|
||||||
currentType = types.video;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Replace current history state
|
|
||||||
if(currentType in types) {
|
|
||||||
history.replaceState({ 'type': currentType }, '', (video ? '' : '#' + currentType));
|
|
||||||
}
|
|
||||||
|
|
||||||
// If it's not video, load the source
|
|
||||||
if(currentType !== types.video) {
|
|
||||||
newSource(currentType, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Toggle class on an element
|
|
||||||
function toggleClass(element, className, state) {
|
|
||||||
if (element) {
|
|
||||||
if (element.classList) {
|
|
||||||
element.classList[state ? 'add' : 'remove'](className);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var name = (' ' + element.className + ' ').replace(/\s+/g, ' ').replace(' ' + className + ' ', '');
|
|
||||||
element.className = name + (state ? ' ' + className : '');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set a new source
|
|
||||||
function newSource(type, init) {
|
|
||||||
// Bail if new type isn't known, it's the current type, or current type is empty (video is default) and new type is video
|
|
||||||
if(!(type in types) || (!init && type == currentType) || (!currentType.length && type == types.video)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get plyr instance
|
|
||||||
var player = document.querySelector('.js-media-player').plyr;
|
|
||||||
|
|
||||||
switch(type) {
|
|
||||||
case types.video:
|
|
||||||
player.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: true
|
|
||||||
}]
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
|
|
||||||
case types.audio:
|
|
||||||
player.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 types.youtube:
|
|
||||||
player.source({
|
|
||||||
type: 'video',
|
|
||||||
title: 'View From A Blue Moon',
|
|
||||||
sources: [{
|
|
||||||
src: 'bTqVqk7FSmY',
|
|
||||||
type: 'youtube'
|
|
||||||
}]
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
|
|
||||||
case types.vimeo:
|
|
||||||
player.source({
|
|
||||||
type: 'video',
|
|
||||||
title: 'View From A Blue Moon',
|
|
||||||
sources: [{
|
|
||||||
src: '143418951',
|
|
||||||
type: 'vimeo'
|
|
||||||
}]
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the current type for next time
|
|
||||||
currentType = type;
|
|
||||||
|
|
||||||
// Remove active classes
|
|
||||||
for (var x = buttons.length - 1; x >= 0; x--) {
|
|
||||||
toggleClass(buttons[x].parentElement, 'active', false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set active on parent
|
|
||||||
toggleClass(document.querySelector('[data-source="'+ type +'"]').parentElement, 'active', true);
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
|
|
||||||
// Google analytics
|
|
||||||
// For demo site (http://[www.]plyr.io) only
|
|
||||||
if(document.domain.indexOf('plyr.io') > -1) {
|
|
||||||
(function(i,s,o,g,r,a,m){i.GoogleAnalyticsObject=r;i[r]=i[r]||function(){
|
|
||||||
(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');
|
|
||||||
}
|
|
68
gulpfile.js
@ -37,19 +37,19 @@ paths = {
|
|||||||
// Output paths
|
// Output paths
|
||||||
output: path.join(root, "dist/")
|
output: path.join(root, "dist/")
|
||||||
},
|
},
|
||||||
docs: {
|
demo: {
|
||||||
// Source paths
|
// Source paths
|
||||||
src: {
|
src: {
|
||||||
less: path.join(root, "docs/src/less/**/*"),
|
less: path.join(root, "demo/src/less/**/*"),
|
||||||
js: path.join(root, "docs/src/js/**/*"),
|
js: path.join(root, "demo/src/js/**/*"),
|
||||||
sprite: path.join(root, "docs/src/sprite/**/*")
|
sprite: path.join(root, "demo/src/sprite/**/*")
|
||||||
},
|
},
|
||||||
// Output paths
|
// Output paths
|
||||||
output: path.join(root, "docs/dist/"),
|
output: path.join(root, "demo/dist/"),
|
||||||
// Docs
|
// Demo
|
||||||
root: path.join(root, "docs/")
|
root: path.join(root, "demo/")
|
||||||
},
|
},
|
||||||
upload: [path.join(root, "dist/**"), path.join(root, "docs/dist/**")]
|
upload: [path.join(root, "dist/**"), path.join(root, "demo/dist/**")]
|
||||||
},
|
},
|
||||||
|
|
||||||
// Task arrays
|
// Task arrays
|
||||||
@ -178,10 +178,10 @@ build.less(bundles.plyr.less, "plyr");
|
|||||||
build.scss(bundles.plyr.scss, "plyr");
|
build.scss(bundles.plyr.scss, "plyr");
|
||||||
build.sprite("plyr");
|
build.sprite("plyr");
|
||||||
|
|
||||||
// Docs files
|
// Demo files
|
||||||
build.less(bundles.docs.less, "docs");
|
build.less(bundles.demo.less, "demo");
|
||||||
build.js(bundles.docs.js, "docs");
|
build.js(bundles.demo.js, "demo");
|
||||||
build.sprite("docs");
|
build.sprite("demo");
|
||||||
|
|
||||||
// Build all JS
|
// Build all JS
|
||||||
gulp.task("js", function(){
|
gulp.task("js", function(){
|
||||||
@ -200,10 +200,10 @@ gulp.task("watch", function () {
|
|||||||
gulp.watch(paths.plyr.src.less, tasks.less);
|
gulp.watch(paths.plyr.src.less, tasks.less);
|
||||||
gulp.watch(paths.plyr.src.sprite, tasks.sprite);
|
gulp.watch(paths.plyr.src.sprite, tasks.sprite);
|
||||||
|
|
||||||
// Docs
|
// Demo
|
||||||
gulp.watch(paths.docs.src.js, tasks.js);
|
gulp.watch(paths.demo.src.js, tasks.js);
|
||||||
gulp.watch(paths.docs.src.less, tasks.less);
|
gulp.watch(paths.demo.src.less, tasks.less);
|
||||||
gulp.watch(paths.docs.src.sprite, tasks.sprite);
|
gulp.watch(paths.demo.src.sprite, tasks.sprite);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Default gulp task
|
// Default gulp task
|
||||||
@ -211,7 +211,7 @@ gulp.task("default", function(){
|
|||||||
run(tasks.js, tasks.less, tasks.sprite, "watch");
|
run(tasks.js, tasks.less, tasks.sprite, "watch");
|
||||||
});
|
});
|
||||||
|
|
||||||
// Publish a version to CDN and docs
|
// Publish a version to CDN and demo
|
||||||
// --------------------------------------------
|
// --------------------------------------------
|
||||||
|
|
||||||
// Some options
|
// Some options
|
||||||
@ -225,7 +225,7 @@ options = {
|
|||||||
"Vary": "Accept-Encoding"
|
"Vary": "Accept-Encoding"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
docs: {
|
demo: {
|
||||||
headers: {
|
headers: {
|
||||||
"Cache-Control": "no-cache, no-store, must-revalidate, max-age=0",
|
"Cache-Control": "no-cache, no-store, must-revalidate, max-age=0",
|
||||||
"Vary": "Accept-Encoding"
|
"Vary": "Accept-Encoding"
|
||||||
@ -264,12 +264,13 @@ gulp.task("cdn", function () {
|
|||||||
.pipe(rename(function (path) {
|
.pipe(rename(function (path) {
|
||||||
path.dirname = path.dirname.replace(".", version);
|
path.dirname = path.dirname.replace(".", version);
|
||||||
}))
|
}))
|
||||||
|
.pipe(replace(localPath, versionPath))
|
||||||
.pipe(s3(aws.cdn, options.cdn));
|
.pipe(s3(aws.cdn, options.cdn));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Publish to Docs bucket
|
// Publish to demo bucket
|
||||||
gulp.task("docs", function () {
|
gulp.task("demo", function () {
|
||||||
console.log("Uploading " + version + " docs to " + aws.docs.bucket + "...");
|
console.log("Uploading " + version + " demo to " + aws.demo.bucket + "...");
|
||||||
|
|
||||||
// Replace versioned files in readme.md
|
// Replace versioned files in readme.md
|
||||||
gulp.src([root + "/readme.md"])
|
gulp.src([root + "/readme.md"])
|
||||||
@ -279,21 +280,22 @@ gulp.task("docs", function () {
|
|||||||
// 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(gulp.dest(path.join(root, "src/js/")));
|
.pipe(gulp.dest(path.join(root, "src/js/")));
|
||||||
|
|
||||||
// Replace local file paths with remote paths in docs
|
// Replace local file paths with remote paths in demo HTML
|
||||||
// e.g. "../dist/plyr.js" to "https://cdn.plyr.io/x.x.x/plyr.js"
|
// e.g. "../dist/plyr.js" to "https://cdn.plyr.io/x.x.x/plyr.js"
|
||||||
gulp.src([paths.docs.root + "*.html"])
|
gulp.src([paths.demo.root + "*.html"])
|
||||||
.pipe(replace(localPath, versionPath))
|
.pipe(replace(localPath, versionPath))
|
||||||
.pipe(s3(aws.docs, options.docs));
|
.pipe(s3(aws.demo, options.demo));
|
||||||
|
|
||||||
// Upload error.html to cdn (as well as docs site)
|
// Upload error.html to cdn (as well as demo site)
|
||||||
return gulp.src([paths.docs.root + "error.html"])
|
return gulp.src([paths.demo.root + "error.html"])
|
||||||
.pipe(replace(localPath, versionPath))
|
.pipe(replace(localPath, versionPath))
|
||||||
.pipe(s3(aws.cdn, options.docs));
|
.pipe(s3(aws.cdn, options.demo));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Open the docs site to check it's sweet
|
// Open the demo site to check it's sweet
|
||||||
gulp.task("symlinks", function () {
|
gulp.task("symlinks", function () {
|
||||||
console.log("Updating symlinks...");
|
console.log("Updating symlinks...");
|
||||||
|
|
||||||
@ -316,20 +318,20 @@ gulp.task("symlinks", function () {
|
|||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Open the docs 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.docs.bucket + "...");
|
console.log("Opening " + aws.demo.bucket + "...");
|
||||||
|
|
||||||
// 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.docs.root + "index.html"])
|
return gulp.src([paths.demo.root + "index.html"])
|
||||||
.pipe(open("", {
|
.pipe(open("", {
|
||||||
url: "http://" + aws.docs.bucket
|
url: "http://" + aws.demo.bucket
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Do everything
|
// Do everything
|
||||||
gulp.task("publish", function () {
|
gulp.task("publish", function () {
|
||||||
run(tasks.js, tasks.less, tasks.sprite, "cdn", "docs", "symlinks");
|
run(tasks.js, tasks.less, tasks.sprite, "cdn", "demo", "symlinks");
|
||||||
});
|
});
|
||||||
|
10
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "plyr",
|
"name": "plyr",
|
||||||
"version": "1.6.11",
|
"version": "1.8.12",
|
||||||
"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",
|
||||||
@ -27,7 +27,11 @@
|
|||||||
"keywords": [
|
"keywords": [
|
||||||
"HTML5 Video",
|
"HTML5 Video",
|
||||||
"HTML5 Audio",
|
"HTML5 Audio",
|
||||||
"Media Player"
|
"Media Player",
|
||||||
|
"DASH",
|
||||||
|
"Shaka",
|
||||||
|
"WordPress",
|
||||||
|
"HLS"
|
||||||
],
|
],
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -38,7 +42,7 @@
|
|||||||
"url": "https://github.com/selz/plyr/issues"
|
"url": "https://github.com/selz/plyr/issues"
|
||||||
},
|
},
|
||||||
"directories": {
|
"directories": {
|
||||||
"doc": "docs"
|
"doc": "readme.md"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
284
readme.md
@ -3,7 +3,7 @@ A simple, accessible and customizable HTML5, YouTube and Vimeo media player.
|
|||||||
|
|
||||||
[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.
|
||||||
@ -21,6 +21,8 @@ We wanted a lightweight, accessible and customizable media player that supports
|
|||||||
- **[Fullscreen](#fullscreen)** - supports native fullscreen with fallback to "full window" modes
|
- **[Fullscreen](#fullscreen)** - supports native fullscreen with fallback to "full window" modes
|
||||||
- **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
|
||||||
|
- **[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.
|
||||||
|
|
||||||
@ -37,22 +39,27 @@ Check out the [changelog](changelog.md) to see what's new with Plyr.
|
|||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
## Implementation
|
## CMS plugins
|
||||||
Check `docs/index.html` and `docs/dist/docs.js` for an example setup.
|
|
||||||
|
|
||||||
**Heads up:** the example `index.html` file needs to be served from a webserver (such as Apache, Nginx, IIS or similar) unless you change the file sources to include http or https. e.g. change `//cdn.plyr.io/1.6.11/plyr.js` to `https://cdn.plyr.io/1.6.11/plyr.js`
|
### [WordPress](https://wordpress.org/plugins/plyr/)
|
||||||
|
Created and maintained by Ryan Anthony Drake ([@iamryandrake](https://github.com/iamryandrake))
|
||||||
|
|
||||||
|
### [Neos](https://packagist.org/packages/jonnitto/plyr)
|
||||||
|
Created and maintained by Jon Uhlmann ([@jonnitto](https://github.com/jonnitto))
|
||||||
|
|
||||||
|
### [Kirby](https://github.com/dpschen/kirby-plyrtag)
|
||||||
|
Created and maintained by Dominik Pschenitschni ([@dpschen](https://github.com/dpschen))
|
||||||
|
|
||||||
|
## Using package managers
|
||||||
|
You can grab the source using one of the following package managers.
|
||||||
|
|
||||||
### npm
|
### npm
|
||||||
|
|
||||||
Using `npm`, you can grab Plyr:
|
|
||||||
```
|
```
|
||||||
npm install plyr
|
npm install plyr
|
||||||
```
|
```
|
||||||
[https://www.npmjs.com/package/plyr](https://www.npmjs.com/package/plyr)
|
[https://www.npmjs.com/package/plyr](https://www.npmjs.com/package/plyr)
|
||||||
|
|
||||||
### Bower
|
### Bower
|
||||||
|
|
||||||
If bower is your thang, you can grab Plyr using:
|
|
||||||
```
|
```
|
||||||
bower install plyr
|
bower install plyr
|
||||||
```
|
```
|
||||||
@ -67,55 +74,84 @@ 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)
|
||||||
|
|
||||||
### CDN
|
## Quick setup
|
||||||
If you want to use our CDN, you can use the following:
|
Here's a quick run through on getting up and running.
|
||||||
|
|
||||||
|
### HTML
|
||||||
|
Plyr extends upon the standard HTML5 markup so that's all you need for those types.
|
||||||
|
|
||||||
|
#### HTML5 Video
|
||||||
```html
|
```html
|
||||||
<link rel="stylesheet" href="https://cdn.plyr.io/1.6.11/plyr.css">
|
<video poster="/path/to/poster.jpg" controls>
|
||||||
<script src="https://cdn.plyr.io/1.6.11/plyr.js"></script>
|
<source src="/path/to/video.mp4" type="video/mp4">
|
||||||
|
<source src="/path/to/video.webm" type="video/webm">
|
||||||
|
<!-- Captions are optional -->
|
||||||
|
<track kind="captions" label="English captions" src="/path/to/captions.vtt" srclang="en" default>
|
||||||
|
</video>
|
||||||
```
|
```
|
||||||
|
|
||||||
The SVG sprite/defs file can be found here: `https://cdn.plyr.io/1.6.11/plyr.svg`.
|
#### HTML5 Audio
|
||||||
|
|
||||||
### CSS & Styling
|
|
||||||
If you want to use the default css, add the `plyr.css` file from `/dist` into your head, or even better use `plyr.less` or `plyr.scss` file included in `/src` in your build to save a request.
|
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<link rel="stylesheet" href="dist/plyr.css">
|
<audio controls>
|
||||||
|
<source src="/path/to/audio.mp3" type="audio/mp3">
|
||||||
|
<source src="/path/to/audio.ogg" type="audio/ogg">
|
||||||
|
</audio>
|
||||||
```
|
```
|
||||||
|
|
||||||
The default setup uses the BEM methodology with `plyr` as the block, e.g. `.plyr__controls`. You can change the class hooks in the options. Check out the source for more on this.
|
For YouTube and Vimeo, Plyr uses the standard YouTube API markup (an empty `<div>`):
|
||||||
|
|
||||||
|
#### YouTube embed
|
||||||
|
```html
|
||||||
|
<div data-type="youtube" data-video-id="bTqVqk7FSmY"></div>
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Vimeo embed
|
||||||
|
```html
|
||||||
|
<div data-type="vimeo" data-video-id="143418951"></div>
|
||||||
|
```
|
||||||
|
|
||||||
|
### 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).
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script src="path/to/plyr.js"></script>
|
||||||
|
<script>plyr.setup();</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
If you want to use our CDN for the JavaScript, you can use the following:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script src="https://cdn.plyr.io/1.8.12/plyr.js"></script>
|
||||||
|
```
|
||||||
|
|
||||||
|
### CSS
|
||||||
|
Include the `plyr.css` stylsheet into your `<head>`
|
||||||
|
|
||||||
|
```html
|
||||||
|
<link rel="stylesheet" href="path/to/plyr.css">
|
||||||
|
```
|
||||||
|
|
||||||
|
If you want to use our CDN for the default CSS, you can use the following:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<link rel="stylesheet" href="https://cdn.plyr.io/1.8.12/plyr.css">
|
||||||
|
```
|
||||||
|
|
||||||
|
### SVG Sprite
|
||||||
|
The SVG sprite is loaded automatically from our CDN. To change this, see the [options](#Options) below. For reference, the CDN hosted SVG sprite can be found at `https://cdn.plyr.io/1.8.12/plyr.svg`.
|
||||||
|
|
||||||
|
## Advanced
|
||||||
|
|
||||||
|
### 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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
### SVG
|
### SVG
|
||||||
The SVG sprite for the controls icons can be loaded two ways:
|
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).
|
||||||
- By passing the *relative* path to the sprite as the `iconUrl` option; or
|
|
||||||
- Using AJAX, injecting the sprite into a hidden div.
|
|
||||||
|
|
||||||
#### Using the `iconUrl` option
|
#### Using the `iconUrl` option
|
||||||
This method requires the SVG sprite to be hosted on the *same domain* as your page hosting the player. Currently no browser supports cross origin SVG sprites due to XSS issues. Fingers crossed this will come soon though. An example value for this option would be:
|
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.
|
||||||
```
|
|
||||||
/path/to/plyr.svg
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Using AJAX
|
|
||||||
Using AJAX means you can load the sprite from a different origin. Avoiding the issues above. This is an example script to load an SVG sprite best added before the closing `</body>`, before any other scripts.
|
|
||||||
|
|
||||||
```html
|
|
||||||
<script>
|
|
||||||
(function(d, p){
|
|
||||||
var a = new XMLHttpRequest(),
|
|
||||||
b = d.body;
|
|
||||||
a.open('GET', p, true);
|
|
||||||
a.send();
|
|
||||||
a.onload = function() {
|
|
||||||
var c = d.createElement('div');
|
|
||||||
c.setAttribute('hidden', '');
|
|
||||||
c.innerHTML = a.responseText;
|
|
||||||
b.insertBefore(c, b.childNodes[0]);
|
|
||||||
};
|
|
||||||
})(document, 'https://cdn.plyr.io/1.6.11/plyr.svg');
|
|
||||||
</script>
|
|
||||||
```
|
|
||||||
|
|
||||||
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)
|
||||||
@ -125,106 +161,65 @@ More info on SVG sprites here:
|
|||||||
and the AJAX technique here:
|
and the AJAX technique here:
|
||||||
[http://css-tricks.com/ajaxing-svg-sprite/](http://css-tricks.com/ajaxing-svg-sprite/)
|
[http://css-tricks.com/ajaxing-svg-sprite/](http://css-tricks.com/ajaxing-svg-sprite/)
|
||||||
|
|
||||||
### HTML
|
### Cross Origin (CORS)
|
||||||
The only extra markup that's needed to use plyr is a `<div>` wrapper. Replace the source, poster and captions with urls for your media.
|
You'll notice the `crossorigin` attribute on the example `<video>` elements. This is because the TextTrack captions are loaded from another domain. If your TextTrack captions are also hosted on another domain, you will need to add this attribute and make sure your host has the correct headers setup. For more info on CORS checkout the MDN docs:
|
||||||
```html
|
|
||||||
<div class="plyr">
|
|
||||||
<video poster="/path/to/poster.jpg" controls>
|
|
||||||
<!-- Video files -->
|
|
||||||
<source src="/path/to/video.mp4" type="video/mp4">
|
|
||||||
<source src="/path/to/video.webm" type="video/webm">
|
|
||||||
|
|
||||||
<!-- Text track file -->
|
|
||||||
<track kind="captions" label="English captions" src="/path/to/captions.vtt" srclang="en" default>
|
|
||||||
|
|
||||||
<!-- Fallback for browsers that don't support the <video> element -->
|
|
||||||
<a href="/path/to/movie.mp4">Download</a>
|
|
||||||
</video>
|
|
||||||
</div>
|
|
||||||
```
|
|
||||||
And the same for `<audio>`
|
|
||||||
|
|
||||||
```html
|
|
||||||
<div class="plyr">
|
|
||||||
<audio controls>
|
|
||||||
<!-- Audio files -->
|
|
||||||
<source src="/path/to/audio.mp3" type="audio/mp3">
|
|
||||||
<source src="/path/to/audio.ogg" type="audio/ogg">
|
|
||||||
|
|
||||||
<!-- Fallback for browsers that don't support the <audio> element -->
|
|
||||||
<a href="/path/to/audio.mp3">Download</a>
|
|
||||||
</audio>
|
|
||||||
</div>
|
|
||||||
```
|
|
||||||
|
|
||||||
For YouTube and Vimeo, Plyr uses the standard YouTube API markup (an empty `<div>`):
|
|
||||||
|
|
||||||
```html
|
|
||||||
<div class="plyr">
|
|
||||||
<div data-video-id="bTqVqk7FSmY" data-type="youtube"></div>
|
|
||||||
</div>
|
|
||||||
```
|
|
||||||
```html
|
|
||||||
<div class="plyr">
|
|
||||||
<div data-video-id="143418951" data-type="vimeo"></div>
|
|
||||||
</div>
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Cross Origin (CORS)
|
|
||||||
You'll notice the `crossorigin` attribute on the example `<video>` and `<audio>` elements. This is because the media is loaded from another domain. If your media is hosted on another domain, you may need to add this attribute.
|
|
||||||
|
|
||||||
More info on CORS here:
|
|
||||||
[https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS)
|
[https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS)
|
||||||
|
|
||||||
### Captions
|
### Captions
|
||||||
WebVTT captions are supported. To add a caption track, check the HTML example above and look for the `<track>` element.
|
WebVTT captions are supported. To add a caption track, check the HTML example above and look for the `<track>` element. Be sure to [validate your caption files](https://quuz.org/webvtt/).
|
||||||
|
|
||||||
Be sure to [validate your caption files](https://quuz.org/webvtt/)
|
|
||||||
|
|
||||||
### JavaScript
|
### JavaScript
|
||||||
|
|
||||||
#### Quick setup
|
#### Initialising
|
||||||
|
|
||||||
Here's an example of a default setup:
|
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, Array of HTMLElements or string selector as below:
|
||||||
|
|
||||||
```html
|
|
||||||
<script src="https://cdn.plyr.io/1.6.11/plyr.js"></script>
|
|
||||||
<script>plyr.setup();</script>
|
|
||||||
```
|
|
||||||
|
|
||||||
This will look for all elements with the specified container classname (default is `plyr`) and setup plyr on each element found. You can specify other options, including a different selector hook below. The container classname will be added to the specified element(s) if it is not already present (for the CSS).
|
|
||||||
|
|
||||||
You can initialize the player a few other ways:
|
|
||||||
|
|
||||||
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
|
||||||
plyr.setup(document.querySelectorAll('.js-plyr'), options);
|
plyr.setup(document.querySelectorAll('.js-player'), options);
|
||||||
```
|
```
|
||||||
|
|
||||||
Passing a [HTMLElement](https://developer.mozilla.org/en/docs/Web/API/HTMLElement):
|
Passing a [HTMLElement](https://developer.mozilla.org/en/docs/Web/API/HTMLElement):
|
||||||
```javascript
|
```javascript
|
||||||
plyr.setup(document.querySelector('.js-plyr'), 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'),
|
||||||
|
document.querySelector('.another-js-player')
|
||||||
|
], 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-plyr', 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.
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
#### 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 (e.g. data-plyr='{ title: "testing" }') - note the single quotes encapsulating the JSON.
|
```html
|
||||||
|
<video data-plyr='{ title: "testing" }'></video>
|
||||||
|
```
|
||||||
|
|
||||||
|
Note the single quotes encapsulating the JSON and double quotes on the object keys.
|
||||||
|
|
||||||
<table class="table" width="100%">
|
<table class="table" width="100%">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th width="20%">Option</th>
|
<th width="20%">Option</th>
|
||||||
<th width="15%">Type</th>
|
<th width="15%">Type</th>
|
||||||
@ -258,16 +253,22 @@ Options must be passed as an object to the `setup()` method as above or as JSON
|
|||||||
<td>Used for internationalization (i18n) of the tooltips/labels within the buttons.</td>
|
<td>Used for internationalization (i18n) of the tooltips/labels within the buttons.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>iconPrefix</code></td>
|
<td><code>loadSprite</code></td>
|
||||||
<td>String</td>
|
<td>Boolean</td>
|
||||||
<td><code>plyr</code></td>
|
<td><code>true</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 defs file but with the default controls. Most people can ignore this option.</td>
|
<td>Load the SVG sprite specified as the <code>iconUrl</code> option (if a URL). If <code>false</code>, it is assumed you are handling sprite loading yourself.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>iconUrl</code></td>
|
<td><code>iconUrl</code></td>
|
||||||
<td>String</td>
|
<td>String</td>
|
||||||
<td><code>null</code></td>
|
<td><code>null</code></td>
|
||||||
<td>Specify a relative path to the SVG sprite, hosted on the *same domain* as the page the player is hosted on. Using this menthod means no requirement for the AJAX sprite loading script. See the <a href="#svg">SVG section</a> for more info.</td>
|
<td>Specify a URL or path to the SVG sprite. See the <a href="#svg">SVG section</a> for more info.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>iconPrefix</code></td>
|
||||||
|
<td>String</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>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>debug</code></td>
|
<td><code>debug</code></td>
|
||||||
@ -299,6 +300,12 @@ Options must be passed as an object to the `setup()` method as above or as JSON
|
|||||||
<td><code>true</code></td>
|
<td><code>true</code></td>
|
||||||
<td>Click (or tap) of the video container will toggle pause/play.</td>
|
<td>Click (or tap) of the video container will toggle pause/play.</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>disableContextMenu</code></td>
|
||||||
|
<td>Boolean</td>
|
||||||
|
<td><code>true</code></td>
|
||||||
|
<td>Disable right click menu on video to <em>help</em> as very primitive obfuscation to prevent downloads of content.</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>hideControls</code></td>
|
<td><code>hideControls</code></td>
|
||||||
<td>Boolean</td>
|
<td>Boolean</td>
|
||||||
@ -375,7 +382,7 @@ Options must be passed as an object to the `setup()` method as above or as JSON
|
|||||||
#### Fullscreen options
|
#### Fullscreen options
|
||||||
|
|
||||||
<table class="table" width="100%" id="fullscreen-options">
|
<table class="table" width="100%" id="fullscreen-options">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th width="20%">Option</th>
|
<th width="20%">Option</th>
|
||||||
<th width="15%">Type</th>
|
<th width="15%">Type</th>
|
||||||
@ -407,22 +414,24 @@ Options must be passed as an object to the `setup()` method as above or as JSON
|
|||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
#### Fetching the plyr instance
|
#### Getting the `plyr` 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.
|
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-plyr`) like so:
|
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:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var player = document.querySelector('.js-plyr').plyr;
|
var player = document.querySelector('.js-player').plyr;
|
||||||
```
|
```
|
||||||
|
|
||||||
Or you can use the returned object from your call to the setup method:
|
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).
|
||||||
|
|
||||||
|
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-plyr')[0];
|
var player = plyr.setup('.js-player')[0].plyr;
|
||||||
```
|
```
|
||||||
|
|
||||||
This will return an array of plyr instances setup, so you need to specify the index of the instance you want. This is less useful if you are setting up mutliple instances. You can listen for the `setup` [event](#events) documented below which will return each instance one by one, as they are setup (in the `plyr` key of the event object).
|
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.
|
||||||
|
|
||||||
Once you have your instance, you can use the API methods below on it. For example to pause it:
|
Once you have your instance, you can use the API methods below on it. For example to pause it:
|
||||||
|
|
||||||
@ -537,11 +546,15 @@ Here's a list of the methods supported:
|
|||||||
<td>—</td>
|
<td>—</td>
|
||||||
<td>Reverses the effects of the <code>destroy()</code> method, restoring the UI and listeners.</td>
|
<td>Reverses the effects of the <code>destroy()</code> method, restoring the UI and listeners.</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>getCurrentTime()</code></td>
|
||||||
|
<td>—</td>
|
||||||
|
<td>Will return a float with the current time in seconds.</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
#### .source() method
|
#### .source() method
|
||||||
|
|
||||||
This allows changing the plyr source and type on the fly.
|
This allows changing the plyr source and type on the fly.
|
||||||
|
|
||||||
Video example:
|
Video example:
|
||||||
@ -651,9 +664,7 @@ Some more details on the object parameters
|
|||||||
</tbody>
|
</tbody>
|
||||||
</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.
|
||||||
|
|
||||||
<table class="table" width="100%">
|
<table class="table" width="100%">
|
||||||
@ -793,8 +804,9 @@ document.querySelector('.js-plyr').addEventListener('ready', function(event) {
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
## Embeds
|
These events also bubble up the DOM.
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
|
||||||
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.
|
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.
|
||||||
@ -819,9 +831,15 @@ More info on the respective API's here:
|
|||||||
|
|
||||||
*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.
|
||||||
|
|
||||||
## Fullscreen
|
## 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:
|
||||||
|
|
||||||
Fullscreen in Plyr is supported for 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.
|
- Using [hls.js](https://github.com/dailymotion/hls.js) - [Demo](http://codepen.io/sampotts/pen/JKEMqB)
|
||||||
|
- Using [Shaka](https://github.com/google/shaka-player) - [Demo](http://codepen.io/sampotts/pen/zBNpVR)
|
||||||
|
- Using [dash.js](https://github.com/Dash-Industry-Forum/dash.js) - [Demo](http://codepen.io/sampotts/pen/BzpJXN)
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
|
||||||
## Browser support
|
## Browser support
|
||||||
|
|
||||||
@ -848,7 +866,7 @@ Fullscreen in Plyr is supported for all browsers that [currently support it](htt
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
¹ Mobile Safari on the iPhone forces the native player for `<video>` so no useful customisation is possible. `<audio>` elements have volume controls disabled.
|
¹ Mobile Safari on the iPhone forces the native player for `<video>` so no useful customization is possible. `<audio>` elements have volume controls disabled.
|
||||||
|
|
||||||
² 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+)
|
||||||
|
|
||||||
|
692
src/js/plyr.js
@ -19,7 +19,8 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
min-width: 200px;
|
min-width: 200px;
|
||||||
font-family: Avenir, "Avenir Next", "Helvetica Neue", "Segoe UI", Helvetica, Arial, sans-serif;
|
font-family: @plyr-font-family;
|
||||||
|
direction: ltr;
|
||||||
|
|
||||||
& when (@plyr-border-box = true) {
|
& when (@plyr-border-box = true) {
|
||||||
// border-box everything
|
// border-box everything
|
||||||
@ -177,7 +178,6 @@
|
|||||||
padding-bottom: 56.25%; /* 16:9 */
|
padding-bottom: 56.25%; /* 16:9 */
|
||||||
height: 0;
|
height: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
border-radius: inherit;
|
|
||||||
|
|
||||||
iframe {
|
iframe {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@ -225,6 +225,8 @@
|
|||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
padding: floor(@plyr-control-spacing / 3) @plyr-control-spacing;
|
padding: floor(@plyr-control-spacing / 3) @plyr-control-spacing;
|
||||||
background: @plyr-captions-bg;
|
background: @plyr-captions-bg;
|
||||||
|
box-decoration-break: clone;
|
||||||
|
line-height: 150%;
|
||||||
}
|
}
|
||||||
span:empty {
|
span:empty {
|
||||||
display: none;
|
display: none;
|
||||||
@ -246,16 +248,18 @@
|
|||||||
|
|
||||||
// Controls
|
// Controls
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
|
// Hide native controls
|
||||||
|
.plyr ::-webkit-media-controls {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
// 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;
|
||||||
|
|
||||||
transition: opacity .3s ease;
|
|
||||||
|
|
||||||
// Spacing
|
// Spacing
|
||||||
> button,
|
> button,
|
||||||
.plyr__progress,
|
.plyr__progress,
|
||||||
@ -280,7 +284,7 @@
|
|||||||
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-padding;
|
||||||
border: 0;
|
border: 0;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
@ -289,8 +293,8 @@
|
|||||||
color: inherit;
|
color: inherit;
|
||||||
|
|
||||||
svg {
|
svg {
|
||||||
width: 18px;
|
width: @plyr-control-icon-size;
|
||||||
height: 18px;
|
height: @plyr-control-icon-size;
|
||||||
display: block;
|
display: block;
|
||||||
fill: currentColor;
|
fill: currentColor;
|
||||||
}
|
}
|
||||||
@ -319,6 +323,7 @@
|
|||||||
// Hide controls
|
// Hide controls
|
||||||
.plyr--hide-controls .plyr__controls {
|
.plyr--hide-controls .plyr__controls {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Video controls
|
// Video controls
|
||||||
@ -332,6 +337,7 @@
|
|||||||
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;
|
||||||
|
|
||||||
button {
|
button {
|
||||||
// Hover and tab focus
|
// Hover and tab focus
|
||||||
@ -349,7 +355,6 @@
|
|||||||
border-radius: inherit;
|
border-radius: inherit;
|
||||||
background: @plyr-audio-controls-bg;
|
background: @plyr-audio-controls-bg;
|
||||||
border: @plyr-audio-controls-border;
|
border: @plyr-audio-controls-border;
|
||||||
box-shadow: @plyr-audio-controls-box-shadow;
|
|
||||||
color: @plyr-audio-control-color;
|
color: @plyr-audio-control-color;
|
||||||
|
|
||||||
button {
|
button {
|
||||||
@ -366,6 +371,7 @@
|
|||||||
.plyr__play-large {
|
.plyr__play-large {
|
||||||
display: none;
|
display: none;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
z-index: 1;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translate(-50%, -50%);
|
transform: translate(-50%, -50%);
|
||||||
@ -373,7 +379,7 @@
|
|||||||
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 fade(@plyr-video-controls-bg, 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 .3s ease;
|
||||||
|
|
||||||
@ -480,6 +486,40 @@
|
|||||||
z-index: 3;
|
z-index: 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// First tooltip
|
||||||
|
.plyr__controls button:first-child .plyr__tooltip {
|
||||||
|
left: 0;
|
||||||
|
transform: translate(0, 10px) scale(.8);
|
||||||
|
transform-origin: 0 100%;
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
left: (@plyr-control-icon-size / 2) + @plyr-control-padding;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Last tooltip
|
||||||
|
.plyr__controls button:last-child .plyr__tooltip {
|
||||||
|
right: 0;
|
||||||
|
transform: translate(0, 10px) scale(.8);
|
||||||
|
transform-origin: 100% 100%;
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
left: auto;
|
||||||
|
right: (@plyr-control-icon-size / 2) + @plyr-control-padding;
|
||||||
|
transform: translateX(50%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.plyr__controls button:first-child,
|
||||||
|
.plyr__controls button:last-child {
|
||||||
|
&:hover .plyr__tooltip,
|
||||||
|
&.tab-focus:focus .plyr__tooltip,
|
||||||
|
.plyr__tooltip--visible {
|
||||||
|
transform: translate(0, 0) scale(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Playback progress
|
// Playback progress
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
// <progress> element
|
// <progress> element
|
||||||
@ -624,7 +664,6 @@
|
|||||||
display: inline-block;
|
display: inline-block;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
font-size: @plyr-font-size-small;
|
font-size: @plyr-font-size-small;
|
||||||
line-height: .95;
|
|
||||||
}
|
}
|
||||||
// Media duration hidden on small screens
|
// Media duration hidden on small screens
|
||||||
.plyr__time + .plyr__time {
|
.plyr__time + .plyr__time {
|
||||||
|
@ -11,7 +11,8 @@
|
|||||||
// Colors
|
// Colors
|
||||||
@plyr-color-main: #3498db;
|
@plyr-color-main: #3498db;
|
||||||
|
|
||||||
// Font sizes
|
// Font
|
||||||
|
@plyr-font-family: 'San Francisco', -apple-system, BlinkMacSystemFont, '.SFNSText-Regular', 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;
|
||||||
|
|
||||||
@ -23,14 +24,15 @@
|
|||||||
@plyr-font-size-captions-large: (@plyr-font-size-base * 2);
|
@plyr-font-size-captions-large: (@plyr-font-size-base * 2);
|
||||||
|
|
||||||
// Controls
|
// Controls
|
||||||
|
@plyr-control-icon-size: 18px;
|
||||||
@plyr-control-spacing: 10px;
|
@plyr-control-spacing: 10px;
|
||||||
|
@plyr-control-padding: (@plyr-control-spacing * .7);
|
||||||
@plyr-video-controls-bg: #000;
|
@plyr-video-controls-bg: #000;
|
||||||
@plyr-video-control-color: #fff;
|
@plyr-video-control-color: #fff;
|
||||||
@plyr-video-control-color-hover: #fff;
|
@plyr-video-control-color-hover: #fff;
|
||||||
@plyr-video-control-bg-hover: @plyr-color-main;
|
@plyr-video-control-bg-hover: @plyr-color-main;
|
||||||
@plyr-audio-controls-bg: #fff;
|
@plyr-audio-controls-bg: #fff;
|
||||||
@plyr-audio-controls-border: 1px solid #dbe3e8;
|
@plyr-audio-controls-border: 1px solid #dbe3e8;
|
||||||
@plyr-audio-controls-box-shadow: 0 1px 1px fade(#000, 5%);
|
|
||||||
@plyr-audio-control-color: #565D64;
|
@plyr-audio-control-color: #565D64;
|
||||||
@plyr-audio-control-color-hover: #fff;
|
@plyr-audio-control-color-hover: #fff;
|
||||||
@plyr-audio-control-bg-hover: @plyr-color-main;
|
@plyr-audio-control-bg-hover: @plyr-color-main;
|
||||||
|
@ -19,7 +19,8 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
min-width: 200px;
|
min-width: 200px;
|
||||||
font-family: Avenir, "Avenir Next", "Helvetica Neue", "Segoe UI", Helvetica, Arial, sans-serif;
|
font-family: $plyr-font-family;
|
||||||
|
direction: ltr;
|
||||||
|
|
||||||
@if $plyr-border-box == true {
|
@if $plyr-border-box == true {
|
||||||
// border-box everything
|
// border-box everything
|
||||||
@ -224,6 +225,8 @@
|
|||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
padding: floor($plyr-control-spacing / 3) $plyr-control-spacing;
|
padding: floor($plyr-control-spacing / 3) $plyr-control-spacing;
|
||||||
background: $plyr-captions-bg;
|
background: $plyr-captions-bg;
|
||||||
|
box-decoration-break: clone;
|
||||||
|
line-height: 150%;
|
||||||
}
|
}
|
||||||
span:empty {
|
span:empty {
|
||||||
display: none;
|
display: none;
|
||||||
@ -245,16 +248,18 @@
|
|||||||
|
|
||||||
// Controls
|
// Controls
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
|
// Hide native controls
|
||||||
|
.plyr ::-webkit-media-controls {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
// 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;
|
||||||
|
|
||||||
transition: opacity .3s ease;
|
|
||||||
|
|
||||||
// Spacing
|
// Spacing
|
||||||
> button,
|
> button,
|
||||||
.plyr__progress,
|
.plyr__progress,
|
||||||
@ -288,8 +293,8 @@
|
|||||||
color: inherit;
|
color: inherit;
|
||||||
|
|
||||||
svg {
|
svg {
|
||||||
width: 18px;
|
width: $plyr-control-icon-size;
|
||||||
height: 18px;
|
height: $plyr-control-icon-size;
|
||||||
display: block;
|
display: block;
|
||||||
fill: currentColor;
|
fill: currentColor;
|
||||||
}
|
}
|
||||||
@ -318,6 +323,7 @@
|
|||||||
// Hide controls
|
// Hide controls
|
||||||
.plyr--hide-controls .plyr__controls {
|
.plyr--hide-controls .plyr__controls {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Video controls
|
// Video controls
|
||||||
@ -331,6 +337,7 @@
|
|||||||
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;
|
||||||
|
|
||||||
button {
|
button {
|
||||||
// Hover and tab focus
|
// Hover and tab focus
|
||||||
@ -348,7 +355,6 @@
|
|||||||
border-radius: inherit;
|
border-radius: inherit;
|
||||||
background: $plyr-audio-controls-bg;
|
background: $plyr-audio-controls-bg;
|
||||||
border: $plyr-audio-controls-border;
|
border: $plyr-audio-controls-border;
|
||||||
box-shadow: $plyr-audio-controls-box-shadow;
|
|
||||||
color: $plyr-audio-control-color;
|
color: $plyr-audio-control-color;
|
||||||
|
|
||||||
button {
|
button {
|
||||||
@ -365,6 +371,7 @@
|
|||||||
.plyr__play-large {
|
.plyr__play-large {
|
||||||
display: none;
|
display: none;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
z-index: 1;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translate(-50%, -50%);
|
transform: translate(-50%, -50%);
|
||||||
@ -372,7 +379,7 @@
|
|||||||
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($plyr-video-controls-bg, .85);
|
box-shadow: 0 1px 1px transparentize(#000, .85);
|
||||||
color: $plyr-video-control-color;
|
color: $plyr-video-control-color;
|
||||||
transition: all .3s ease;
|
transition: all .3s ease;
|
||||||
|
|
||||||
@ -479,6 +486,39 @@
|
|||||||
z-index: 3;
|
z-index: 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// First tooltip
|
||||||
|
.plyr__controls button:first-child .plyr__tooltip {
|
||||||
|
left: 0;
|
||||||
|
transform: translate(0, 10px) scale(.8);
|
||||||
|
transform-origin: 0 100%;
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
left: ($plyr-control-icon-size / 2) + $plyr-control-padding;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Last tooltip
|
||||||
|
.plyr__controls button:last-child .plyr__tooltip {
|
||||||
|
right: 0;
|
||||||
|
transform: translate(0, 10px) scale(.8);
|
||||||
|
transform-origin: 100% 100%;
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
left: auto;
|
||||||
|
right: ($plyr-control-icon-size / 2) + $plyr-control-padding;
|
||||||
|
transform: translateX(50%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.plyr__controls button:first-child,
|
||||||
|
.plyr__controls button:last-child {
|
||||||
|
&:hover .plyr__tooltip,
|
||||||
|
&.tab-focus:focus .plyr__tooltip,
|
||||||
|
.plyr__tooltip--visible {
|
||||||
|
transform: translate(0, 0) scale(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Playback progress
|
// Playback progress
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
// <progress> element
|
// <progress> element
|
||||||
@ -623,7 +663,6 @@
|
|||||||
display: inline-block;
|
display: inline-block;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
font-size: $plyr-font-size-small;
|
font-size: $plyr-font-size-small;
|
||||||
line-height: .95;
|
|
||||||
}
|
}
|
||||||
// Media duration hidden on small screens
|
// Media duration hidden on small screens
|
||||||
.plyr__time + .plyr__time {
|
.plyr__time + .plyr__time {
|
||||||
|
@ -13,6 +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 !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;
|
||||||
|
|
||||||
@ -24,14 +25,15 @@ $plyr-font-size-captions-medium: ceil($plyr-font-size-base * 1.5) !defaul
|
|||||||
$plyr-font-size-captions-large: ($plyr-font-size-base * 2) !default;
|
$plyr-font-size-captions-large: ($plyr-font-size-base * 2) !default;
|
||||||
|
|
||||||
// Controls
|
// Controls
|
||||||
|
$plyr-control-icon-size: 18px !default;
|
||||||
$plyr-control-spacing: 10px !default;
|
$plyr-control-spacing: 10px !default;
|
||||||
|
$plyr-control-padding: ($plyr-control-spacing * .7) !default;
|
||||||
$plyr-video-controls-bg: #000 !default;
|
$plyr-video-controls-bg: #000 !default;
|
||||||
$plyr-video-control-color: #fff !default;
|
$plyr-video-control-color: #fff !default;
|
||||||
$plyr-video-control-color-hover: #fff !default;
|
$plyr-video-control-color-hover: #fff !default;
|
||||||
$plyr-video-control-bg-hover: $plyr-color-main !default;
|
$plyr-video-control-bg-hover: $plyr-color-main !default;
|
||||||
$plyr-audio-controls-bg: #fff !default;
|
$plyr-audio-controls-bg: #fff !default;
|
||||||
$plyr-audio-controls-border: 1px solid #dbe3e8 !default;
|
$plyr-audio-controls-border: 1px solid #dbe3e8 !default;
|
||||||
$plyr-audio-controls-box-shadow: 0 1px 1px transparentize(#000, .95) !default;
|
|
||||||
$plyr-audio-control-color: #565D64 !default;
|
$plyr-audio-control-color: #565D64 !default;
|
||||||
$plyr-audio-control-color-hover: #fff !default;
|
$plyr-audio-control-color-hover: #fff !default;
|
||||||
$plyr-audio-control-bg-hover: $plyr-color-main;
|
$plyr-audio-control-bg-hover: $plyr-color-main;
|
||||||
|