Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
c2c4172634 | |||
73de5b5773 | |||
aa1fed0b16 | |||
22331ae9f1 | |||
8b436276bf | |||
c61db87fd6 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,3 +4,4 @@ node_modules
|
||||
.DS_Store
|
||||
aws.json
|
||||
docs/index.dev.html
|
||||
*.mp4
|
||||
|
16
changelog.md
16
changelog.md
@ -1,5 +1,21 @@
|
||||
# Changelog
|
||||
|
||||
## v1.0.31
|
||||
- Display duration on metadataloaded
|
||||
|
||||
## v1.0.30
|
||||
- Fixed bug with media longer than 60 minutes (Fixes #69)
|
||||
|
||||
## 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)
|
||||
- Fixed a bug with caption toggle in 1.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)
|
||||
|
||||
## v1.0.27
|
||||
- Keyboard accessibility improvements (Fixes #66)
|
||||
|
||||
## v1.0.26
|
||||
- Fixes for SASS (cheers @brunowego)
|
||||
- Indentation reset to 4 spaces
|
||||
|
2
dist/plyr.css
vendored
2
dist/plyr.css
vendored
File diff suppressed because one or more lines are too long
2
dist/plyr.js
vendored
2
dist/plyr.js
vendored
File diff suppressed because one or more lines are too long
@ -6,7 +6,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<!-- Docs styles -->
|
||||
<link rel="stylesheet" href="//cdn.plyr.io/1.0.27/docs.css">
|
||||
<link rel="stylesheet" href="//cdn.plyr.io/1.0.31/docs.css">
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
|
@ -8,10 +8,10 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<!-- Styles -->
|
||||
<link rel="stylesheet" href="//cdn.plyr.io/1.0.27/plyr.css">
|
||||
<link rel="stylesheet" href="//cdn.plyr.io/1.0.31/plyr.css">
|
||||
|
||||
<!-- Docs styles -->
|
||||
<link rel="stylesheet" href="//cdn.plyr.io/1.0.27/docs.css">
|
||||
<link rel="stylesheet" href="//cdn.plyr.io/1.0.31/docs.css">
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
@ -67,13 +67,29 @@
|
||||
<!-- Load SVG defs -->
|
||||
<!-- You should bundle all SVG/Icons into one file using a build tool such as gulp and svg store -->
|
||||
<script>
|
||||
(function(d,p){var a=new XMLHttpRequest(),b=d.body;a.open("GET",p,!0);a.send();a.onload=function(){var c=d.createElement("div");c.style.display="none";c.innerHTML=a.responseText;b.insertBefore(c,b.childNodes[0])}})(document,"//cdn.plyr.io/1.0.27/sprite.svg");
|
||||
(function(d, u){
|
||||
var a = new XMLHttpRequest(),
|
||||
b = d.body;
|
||||
|
||||
// Check for CORS support
|
||||
// If you're loading from same domain, you can remove the if statement
|
||||
if("withCredentials" in a) {
|
||||
a.open("GET", u, true);
|
||||
a.send();
|
||||
a.onload = function(){
|
||||
var c = d.createElement("div");
|
||||
c.style.display="none";
|
||||
c.innerHTML = a.responseText;
|
||||
b.insertBefore(c, b.childNodes[0]);
|
||||
}
|
||||
}
|
||||
})(document, "https://cdn.plyr.io/1.0.31/sprite.svg");
|
||||
</script>
|
||||
|
||||
<!-- Plyr core script -->
|
||||
<script src="//cdn.plyr.io/1.0.27/plyr.js"></script>
|
||||
<script src="//cdn.plyr.io/1.0.31/plyr.js"></script>
|
||||
|
||||
<!-- Docs script -->
|
||||
<script src="//cdn.plyr.io/1.0.27/docs.js"></script>
|
||||
<script src="//cdn.plyr.io/1.0.31/docs.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "plyr",
|
||||
"version": "1.0.27",
|
||||
"version": "1.0.31",
|
||||
"description": "A simple HTML5 media player using custom controls",
|
||||
"homepage": "http://plyr.io",
|
||||
"main": "gulpfile.js",
|
||||
|
26
readme.md
26
readme.md
@ -10,7 +10,7 @@ We wanted a lightweight, accessible and customisable media player that just supp
|
||||
|
||||
## Features
|
||||
- **Accessible** - full support for captions and screen readers.
|
||||
- **Lightweight** - just 5.7KB minified and gzipped.
|
||||
- **Lightweight** - just 6KB minified and gzipped.
|
||||
- **Customisable** - make the player look how you want with the markup you want.
|
||||
- **Semantic** - uses the *right* elements. `<input type="range">` for volume and `<progress>` for progress and well, `<button>`s for buttons. There's no `<span>` or `<a href="#">` button hacks.
|
||||
- **Responsive** - as you'd expect these days.
|
||||
@ -38,7 +38,7 @@ If you have any cool ideas or features, please let me know by [creating an issue
|
||||
|
||||
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.0.27/plyr.js` to `https://cdn.plyr.io/1.0.27/plyr.js`
|
||||
**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.0.31/plyr.js` to `https://cdn.plyr.io/1.0.31/plyr.js`
|
||||
|
||||
### Bower
|
||||
If bower is your thang, you can grab Plyr using:
|
||||
@ -51,11 +51,11 @@ More info on setting up dependencies can be found in the [Bower Docs](http://bow
|
||||
If you want to use our CDN, you can use the following. HTTPS (SSL) is supported.
|
||||
|
||||
```html
|
||||
<link rel="stylesheet" href="//cdn.plyr.io/1.0.27/plyr.css">
|
||||
<script src="//cdn.plyr.io/1.0.27/plyr.js"></script>
|
||||
<link rel="stylesheet" href="//cdn.plyr.io/1.0.31/plyr.css">
|
||||
<script src="//cdn.plyr.io/1.0.31/plyr.js"></script>
|
||||
```
|
||||
|
||||
You can also access the `sprite.svg` file at `//cdn.plyr.io/1.0.27/sprite.svg`.
|
||||
You can also access the `sprite.svg` file at `//cdn.plyr.io/1.0.31/sprite.svg`.
|
||||
|
||||
### CSS
|
||||
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.sass` file included in `/src` in your build to save a request.
|
||||
@ -197,6 +197,12 @@ You can pass the following options to the setup method.
|
||||
<td>Boolean</td>
|
||||
<td><code>false</code></td>
|
||||
<td>Display control labels as tooltips on :hover & :focus (by default, the labels are screen reader only).</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>displayDuration</code></td>
|
||||
<td>Boolean</td>
|
||||
<td><code>true</code></td>
|
||||
<td>Displays the duration of the media on the "metadataloaded" event (on startup). This will only work if the `preload` attribute is not set to `none`. It is `auto` by default (if the attribute is not present).</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>selectors</code></td>
|
||||
@ -220,7 +226,7 @@ You can pass the following options to the setup method.
|
||||
<td><code>fullscreen</code></td>
|
||||
<td>Object</td>
|
||||
<td>—</td>
|
||||
<td>Two properties; <code>enabled</code> which toggles if fullscreen should be enabled (if the browser supports it). The default value is <code>true</code>. Also an extra property called <code>fallback</code> which will enable a full window view for older browsers. The default value is <code>true</code>.</td>
|
||||
<td>Three properties; <code>enabled</code> which toggles if fullscreen should be enabled (if the browser supports it). The default value is <code>true</code>. A <code>fallback</code> property which will enable a full window view for older browsers. The default value is <code>true</code>. A <code>hideControls</code> property which will hide the controls when fullscreen is active and the video is playing, after 1s. The controls reappear on hover of the progress bar (mouse), focusing a child control or pausing the video (by tap/click of video if `click` is `true`). The default value is <code>true</code>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>storage</code></td>
|
||||
@ -359,15 +365,15 @@ Fullscreen in Plyr is supported for all browsers that [currently support it](htt
|
||||
<td>✔</td>
|
||||
<td>✔</td>
|
||||
<td>✔</td>
|
||||
<td>✖²</td>
|
||||
<td>API²</td>
|
||||
<td>✔³</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
¹ iPhone forces the native player for `<video>` so no customisation possible. `<audio>` elements have volume controls disabled.
|
||||
¹ Mobile Safari on the iPhone forces the native player for `<video>` so no useful customisation is possible. `<audio>` elements have volume controls disabled.
|
||||
|
||||
² Native player used (no support for `<progress>` or `<input type="range">`)
|
||||
² Native player used (no support for `<progress>` or `<input type="range">`) but the API is supported (v1.0.28+)
|
||||
|
||||
³ IE10 has no native fullscreen support, fallback can be used (see options)
|
||||
|
||||
@ -389,10 +395,12 @@ Plyr is developed by Sam Potts ([@sam_potts](https://twitter.com/sam_potts)) ([s
|
||||
## Mentions
|
||||
- [The Changelog](http://thechangelog.com/plyr-simple-html5-media-player-custom-controls-webvtt-captions/)
|
||||
- [HTML5 Weekly #177](http://html5weekly.com/issues/177)
|
||||
- [Responsive Design #149](http://us4.campaign-archive2.com/?u=559bc631fe5294fc66f5f7f89&id=451a61490f)
|
||||
- [Web Design Weekly #174](https://web-design-weekly.com/2015/02/24/web-design-weekly-174/)
|
||||
- [Hacker News](https://news.ycombinator.com/item?id=9136774)
|
||||
- [Web Platform Daily](http://webplatformdaily.org/releases/2015-03-04)
|
||||
- [LayerVault Designer News](https://news.layervault.com/stories/45394-plyr--a-simple-html5-media-player)
|
||||
- [The Treehouse Show #131](https://teamtreehouse.com/library/episode-131-origami-react-responsive-hero-images)
|
||||
|
||||
## Used by
|
||||
- [Selz.com](https://selz.com)
|
||||
|
286
src/js/plyr.js
286
src/js/plyr.js
@ -1,6 +1,6 @@
|
||||
// ==========================================================================
|
||||
// Plyr
|
||||
// plyr.js v1.0.27
|
||||
// plyr.js v1.0.31
|
||||
// https://github.com/selz/plyr
|
||||
// License: The MIT License (MIT)
|
||||
// ==========================================================================
|
||||
@ -21,6 +21,7 @@
|
||||
volume: 5,
|
||||
click: true,
|
||||
tooltips: false,
|
||||
displayDuration: true,
|
||||
selectors: {
|
||||
container: ".player",
|
||||
controls: ".player-controls",
|
||||
@ -55,13 +56,15 @@
|
||||
loading: "loading",
|
||||
tooltip: "player-tooltip",
|
||||
hidden: "sr-only",
|
||||
hover: "hover",
|
||||
captions: {
|
||||
enabled: "captions-enabled",
|
||||
active: "captions-active"
|
||||
},
|
||||
fullscreen: {
|
||||
enabled: "fullscreen-enabled",
|
||||
active: "fullscreen-active"
|
||||
active: "fullscreen-active",
|
||||
hideControls: "fullscreen-hide-controls"
|
||||
}
|
||||
},
|
||||
captions: {
|
||||
@ -69,7 +72,8 @@
|
||||
},
|
||||
fullscreen: {
|
||||
enabled: true,
|
||||
fallback: true
|
||||
fallback: true,
|
||||
hideControls: true
|
||||
},
|
||||
storage: {
|
||||
enabled: true,
|
||||
@ -219,7 +223,7 @@
|
||||
// Check for mime type support against a player instance
|
||||
// Credits: http://diveintohtml5.info/everything.html
|
||||
// Related: http://www.leanbackplayer.com/test/h5mt.html
|
||||
function _support(player, mimeType) {
|
||||
function _supportMime(player, mimeType) {
|
||||
var media = player.media;
|
||||
|
||||
// Only check video types for video players
|
||||
@ -365,9 +369,6 @@
|
||||
// Toggle the checkbox
|
||||
event.target.checked = !event.target.checked;
|
||||
|
||||
// Set the attribute for CSS hooks
|
||||
event.target[event.target.checked ? "setAttribute" : "removeAttribute"]("checked", "");
|
||||
|
||||
// Trigger change event
|
||||
_triggerEvent(event.target, "change");
|
||||
}
|
||||
@ -496,7 +497,7 @@
|
||||
// Seek the manual caption time and update UI
|
||||
function _seekManualCaptions(time) {
|
||||
// If it's not video, or we're using textTracks, bail.
|
||||
if (player.usingTextTracks || player.type !== "video") {
|
||||
if (player.usingTextTracks || player.type !== "video" || !player.supported.full) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -536,7 +537,7 @@
|
||||
|
||||
if (config.captions.defaultActive) {
|
||||
_toggleClass(player.container, config.classes.captions.active, true);
|
||||
player.buttons.captions.setAttribute("checked", "");
|
||||
player.buttons.captions.checked = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -681,42 +682,39 @@
|
||||
|
||||
// Setup media
|
||||
function _setupMedia() {
|
||||
player.media = player.container.querySelectorAll("audio, video")[0];
|
||||
|
||||
// If there's no media, bail
|
||||
if(!player.media) {
|
||||
_log("No audio or video element found!", true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remove native video controls
|
||||
player.media.removeAttribute("controls");
|
||||
if(player.supported.full) {
|
||||
// Remove native video controls
|
||||
player.media.removeAttribute("controls");
|
||||
|
||||
// Add type class
|
||||
_toggleClass(player.container, config.classes[player.type], true);
|
||||
|
||||
// Set media type
|
||||
player.type = player.media.tagName.toLowerCase();
|
||||
// If there's no autoplay attribute, assume the video is stopped and add state class
|
||||
_toggleClass(player.container, config.classes.stopped, (player.media.getAttribute("autoplay") === null));
|
||||
|
||||
// Add iOS class
|
||||
if(player.browser.ios) {
|
||||
_toggleClass(player.container, "ios", true);
|
||||
}
|
||||
|
||||
// Add type class
|
||||
_toggleClass(player.container, config.classes[player.type], true);
|
||||
// Inject the player wrapper
|
||||
if(player.type === "video") {
|
||||
// Create the wrapper div
|
||||
var wrapper = document.createElement("div");
|
||||
wrapper.setAttribute("class", config.classes.videoWrapper);
|
||||
|
||||
// If there's no autoplay attribute, assume the video is stopped and add state class
|
||||
_toggleClass(player.container, config.classes.stopped, (player.media.getAttribute("autoplay") === null));
|
||||
// Wrap the video in a container
|
||||
_wrap(player.media, wrapper);
|
||||
|
||||
// Add iOS class
|
||||
if(player.browser.ios) {
|
||||
_toggleClass(player.container, "ios", true);
|
||||
}
|
||||
|
||||
// Inject the player wrapper
|
||||
if(player.type === "video") {
|
||||
// Create the wrapper div
|
||||
var wrapper = document.createElement("div");
|
||||
wrapper.setAttribute("class", config.classes.videoWrapper);
|
||||
|
||||
// Wrap the video in a container
|
||||
_wrap(player.media, wrapper);
|
||||
|
||||
// Cache the container
|
||||
player.videoContainer = wrapper;
|
||||
// Cache the container
|
||||
player.videoContainer = wrapper;
|
||||
}
|
||||
}
|
||||
|
||||
// Autoplay
|
||||
@ -802,10 +800,12 @@
|
||||
|
||||
if (track.kind === "captions") {
|
||||
_on(track, "cuechange", function() {
|
||||
if (this.activeCues[0]) {
|
||||
if (this.activeCues[0].hasOwnProperty("text")) {
|
||||
player.captionsContainer.innerHTML = this.activeCues[0].text;
|
||||
}
|
||||
// Clear container
|
||||
player.captionsContainer.innerHTML = "";
|
||||
|
||||
// Display a cue, if there is one
|
||||
if (this.activeCues[0] && this.activeCues[0].hasOwnProperty("text")) {
|
||||
player.captionsContainer.appendChild(this.activeCues[0].getCueAsHTML());
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -886,6 +886,11 @@
|
||||
else {
|
||||
_log("Fullscreen not supported and fallback disabled.");
|
||||
}
|
||||
|
||||
// Set control hide class hook
|
||||
if(config.fullscreen.hideControls) {
|
||||
_toggleClass(player.container, config.classes.fullscreen.hideControls, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1027,8 +1032,15 @@
|
||||
volume = 10;
|
||||
}
|
||||
|
||||
player.volume.value = volume;
|
||||
// If the controls are there
|
||||
if(player.supported.full) {
|
||||
player.volume.value = volume;
|
||||
}
|
||||
|
||||
// Set the player volume
|
||||
player.media.volume = parseFloat(volume / 10);
|
||||
|
||||
// Update the UI
|
||||
_checkMute();
|
||||
|
||||
// Store the volume in storage
|
||||
@ -1040,29 +1052,35 @@
|
||||
// Mute
|
||||
function _toggleMute(muted) {
|
||||
// If the method is called without parameter, toggle based on current value
|
||||
if(typeof active === "undefined") {
|
||||
if(typeof muted === "undefined") {
|
||||
muted = !player.media.muted;
|
||||
}
|
||||
|
||||
// If the controls are there
|
||||
if(player.supported.full) {
|
||||
player.buttons.mute.checked = muted;
|
||||
}
|
||||
|
||||
// Set mute on the player
|
||||
player.media.muted = muted;
|
||||
|
||||
// Update UI
|
||||
_checkMute();
|
||||
}
|
||||
|
||||
// Toggle captions
|
||||
function _toggleCaptions(active) {
|
||||
// If the method is called without parameter, toggle based on current value
|
||||
if(typeof active === "undefined") {
|
||||
active = (player.container.className.indexOf(config.classes.captions.active) === -1);
|
||||
player.buttons.captions.checked = active;
|
||||
function _toggleCaptions(show) {
|
||||
if(!player.supported.full) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (active) {
|
||||
_toggleClass(player.container, config.classes.captions.active, true);
|
||||
}
|
||||
else {
|
||||
_toggleClass(player.container, config.classes.captions.active);
|
||||
// If the method is called without parameter, toggle based on current value
|
||||
if(typeof show === "undefined") {
|
||||
show = (player.container.className.indexOf(config.classes.captions.active) === -1);
|
||||
player.buttons.captions.checked = show;
|
||||
}
|
||||
|
||||
_toggleClass(player.container, config.classes.captions.active, show);
|
||||
}
|
||||
|
||||
// Check mute state
|
||||
@ -1133,23 +1151,34 @@
|
||||
text.innerHTML = value;
|
||||
}
|
||||
|
||||
// Update the displayed play time
|
||||
function _updateTimeDisplay() {
|
||||
player.secs = parseInt(player.media.currentTime % 60);
|
||||
player.mins = parseInt((player.media.currentTime / 60) % 60);
|
||||
// Update the displayed time
|
||||
function _updateTimeDisplay(time) {
|
||||
player.secs = parseInt(time % 60);
|
||||
player.mins = parseInt((time / 60) % 60);
|
||||
player.hours = parseInt(((time / 60) / 60) % 60);
|
||||
|
||||
// Do we need to display hours?
|
||||
var displayHours = (parseInt(((player.media.duration / 60) / 60) % 60) > 0)
|
||||
|
||||
// Ensure it"s two digits. For example, 03 rather than 3.
|
||||
player.secs = ("0" + player.secs).slice(-2);
|
||||
player.mins = ("0" + player.mins).slice(-2);
|
||||
|
||||
// Render
|
||||
player.duration.innerHTML = player.mins + ":" + player.secs;
|
||||
player.duration.innerHTML = (displayHours ? player.hours + ":" : "") + player.mins + ":" + player.secs;
|
||||
}
|
||||
|
||||
// Show the duration on metadataloaded
|
||||
function _displayDuration() {
|
||||
if(player.media.paused) {
|
||||
_updateTimeDisplay(player.media.duration || 0);
|
||||
}
|
||||
}
|
||||
|
||||
// Handle time change event
|
||||
function _timeUpdate(event) {
|
||||
// Duration
|
||||
_updateTimeDisplay();
|
||||
_updateTimeDisplay(player.media.currentTime);
|
||||
|
||||
// Playing progress
|
||||
_updateProgress(event);
|
||||
@ -1192,9 +1221,6 @@
|
||||
// Restart
|
||||
_seek();
|
||||
|
||||
// Update the UI
|
||||
_checkPlaying();
|
||||
|
||||
// Remove current sources
|
||||
_removeSources();
|
||||
|
||||
@ -1213,8 +1239,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Reset time display
|
||||
_timeUpdate();
|
||||
if(player.supported.full) {
|
||||
// Reset time display
|
||||
_timeUpdate();
|
||||
|
||||
// Update the UI
|
||||
_checkPlaying();
|
||||
}
|
||||
|
||||
// Re-load sources
|
||||
player.media.load();
|
||||
@ -1270,7 +1301,9 @@
|
||||
_on(player.buttons.fullscreen, "click", _toggleFullscreen);
|
||||
|
||||
// Handle user exiting fullscreen by escaping etc
|
||||
_on(document, fullscreen.fullScreenEventName, _toggleFullscreen);
|
||||
if(fullscreen.supportsFullScreen) {
|
||||
_on(document, fullscreen.fullScreenEventName, _toggleFullscreen);
|
||||
}
|
||||
|
||||
// Time change on media
|
||||
_on(player.media, "timeupdate seeking", _timeUpdate);
|
||||
@ -1278,6 +1311,11 @@
|
||||
// Update manual captions
|
||||
_on(player.media, "timeupdate", _seekManualCaptions);
|
||||
|
||||
// Display duration
|
||||
if(config.displayDuration) {
|
||||
_on(player.media, "loadedmetadata", _displayDuration);
|
||||
}
|
||||
|
||||
// Seek
|
||||
_on(player.buttons.seek, "change input", _seek);
|
||||
|
||||
@ -1330,54 +1368,76 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Bind to mouse hover
|
||||
if(config.fullscreen.hideControls) {
|
||||
_on(player.controls, "mouseenter mouseleave", function(event) {
|
||||
_toggleClass(player.controls, config.classes.hover, (event.type === "mouseenter"));
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function _init() {
|
||||
// Setup the fullscreen api
|
||||
fullscreen = _fullscreen();
|
||||
|
||||
// Sniff
|
||||
// Sniff out the browser
|
||||
player.browser = _browserSniff();
|
||||
|
||||
// Get the media element
|
||||
player.media = player.container.querySelectorAll("audio, video")[0];
|
||||
|
||||
// Set media type
|
||||
player.type = player.media.tagName.toLowerCase();
|
||||
|
||||
// Check for full support
|
||||
player.supported = api.supported(player.type);
|
||||
|
||||
// If no native support, bail
|
||||
if(!player.supported.basic) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Debug info
|
||||
_log(player.browser.name + " " + player.browser.version);
|
||||
|
||||
// If IE8, stop customization (use fallback)
|
||||
// If IE9, stop customization (use native controls)
|
||||
if (player.browser.name === "IE" && (player.browser.version === 8 || player.browser.version === 9) ) {
|
||||
_log("Browser not suppported.", true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Setup media
|
||||
_setupMedia();
|
||||
|
||||
// Generate random number for id/for attribute values for controls
|
||||
player.random = Math.floor(Math.random() * (10000));
|
||||
|
||||
// Inject custom controls
|
||||
_injectControls();
|
||||
// If there's full support
|
||||
if(player.supported.full) {
|
||||
// Inject custom controls
|
||||
_injectControls();
|
||||
|
||||
// Find the elements
|
||||
if(!_findElements()) {
|
||||
return false;
|
||||
// Find the elements
|
||||
if(!_findElements()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Display duration if available
|
||||
if(config.displayDuration) {
|
||||
_displayDuration();
|
||||
}
|
||||
|
||||
// Set up aria-label for Play button with the title option
|
||||
_setupAria();
|
||||
|
||||
// Captions
|
||||
_setupCaptions();
|
||||
|
||||
// Set volume
|
||||
_setVolume();
|
||||
|
||||
// Setup fullscreen
|
||||
_setupFullscreen();
|
||||
|
||||
// Listeners
|
||||
_listeners();
|
||||
}
|
||||
|
||||
// Set up aria-label for Play button with the title option
|
||||
_setupAria();
|
||||
|
||||
// Captions
|
||||
_setupCaptions();
|
||||
|
||||
// Set volume
|
||||
_setVolume();
|
||||
|
||||
// Setup fullscreen
|
||||
_setupFullscreen();
|
||||
|
||||
// Listeners
|
||||
_listeners();
|
||||
|
||||
// Successful setup
|
||||
return true;
|
||||
}
|
||||
@ -1399,10 +1459,42 @@
|
||||
toggleCaptions: _toggleCaptions,
|
||||
source: _parseSource,
|
||||
poster: _updatePoster,
|
||||
support: function(mimeType) { return _support(player, mimeType); }
|
||||
support: function(mimeType) { return _supportMime(player, mimeType); }
|
||||
}
|
||||
}
|
||||
|
||||
// Check for support
|
||||
api.supported = function(type) {
|
||||
var browser = _browserSniff(),
|
||||
oldIE = (browser.name === "IE" && browser.version <= 9),
|
||||
iPhone = /iPhone|iPod/i.test(navigator.userAgent),
|
||||
audio = !!document.createElement("audio").canPlayType,
|
||||
video = !!document.createElement("video").canPlayType,
|
||||
basic, full;
|
||||
|
||||
switch (type) {
|
||||
case "video":
|
||||
basic = video;
|
||||
full = (basic && (!oldIE && !iPhone));
|
||||
break;
|
||||
|
||||
case "audio":
|
||||
basic = audio;
|
||||
full = (basic && !oldIE);
|
||||
break;
|
||||
|
||||
default:
|
||||
basic = (audio && video);
|
||||
full = (basic && !oldIE);
|
||||
break;
|
||||
}
|
||||
|
||||
return {
|
||||
basic: basic,
|
||||
full: full
|
||||
};
|
||||
}
|
||||
|
||||
// Expose setup function
|
||||
api.setup = function(options){
|
||||
// Extend the default options with user specified
|
||||
@ -1410,7 +1502,7 @@
|
||||
|
||||
// If enabled carry on
|
||||
// You may want to disable certain UAs etc
|
||||
if(!config.enabled) {
|
||||
if(!config.enabled || !api.supported().basic) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1423,13 +1515,6 @@
|
||||
// Get the current element
|
||||
var element = elements[i];
|
||||
|
||||
// Disabled for <video> for iPhone
|
||||
// Since it doesn't allow customisation
|
||||
if (element.querySelectorAll("audio, video")[0].tagName.toLowerCase() === "video"
|
||||
&& /iPhone/i.test(navigator.userAgent)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Setup a player instance and add to the element
|
||||
if(typeof element.plyr === "undefined") {
|
||||
// Create new instance
|
||||
@ -1445,4 +1530,5 @@
|
||||
|
||||
return players;
|
||||
}
|
||||
|
||||
}(this.plyr = this.plyr || {}));
|
@ -31,9 +31,9 @@
|
||||
@tooltip-radius: 3px;
|
||||
|
||||
// Progress
|
||||
@progress-bg: lighten(@gray, 10%);
|
||||
@progress-bg: rgba(red(@gray), green(@gray), blue(@gray), .2);
|
||||
@progress-playing-bg: @blue;
|
||||
@progress-buffered-bg: @gray;
|
||||
@progress-buffered-bg: rgba(red(@gray), green(@gray), blue(@gray), .25);
|
||||
@progress-loading-size: 40px;
|
||||
@progress-loading-bg: rgba(0,0,0, .15);
|
||||
|
||||
@ -179,7 +179,7 @@
|
||||
.clearfix();
|
||||
.font-smoothing();
|
||||
position: relative;
|
||||
padding: (@control-spacing * 2) @control-spacing @control-spacing;
|
||||
padding: @control-spacing;
|
||||
background: @controls-bg;
|
||||
line-height: 1;
|
||||
text-align: center;
|
||||
@ -313,7 +313,7 @@
|
||||
// <progress> element
|
||||
&-progress {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 100%;
|
||||
left: 0;
|
||||
right: 0;
|
||||
width: 100%;
|
||||
@ -549,6 +549,17 @@
|
||||
left: 0;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
// Hide controls when playing in full screen
|
||||
&.fullscreen-hide-controls.playing .player-controls {
|
||||
transform: translateY(100%) translateY(@control-spacing / 2);
|
||||
transition: transform .3s 1s ease;
|
||||
|
||||
&.hover {
|
||||
transform: translateY(0);
|
||||
transition-delay: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Change icons on state change
|
||||
@ -575,10 +586,4 @@
|
||||
&.fullscreen-enabled [data-player='fullscreen'] + label {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
// Full browser view hides toggle
|
||||
&-fullscreen [data-player='fullscreen'],
|
||||
&-fullscreen [data-player='fullscreen'] + label {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
@ -31,9 +31,9 @@ $tooltip-arrow-size: 5px;
|
||||
$tooltip-radius: 3px;
|
||||
|
||||
// Progress
|
||||
$progress-bg: lighten($gray, 10%);
|
||||
$progress-bg: rgba(red($gray), green($gray), blue($gray), .2);
|
||||
$progress-playing-bg: $blue;
|
||||
$progress-buffered-bg: $gray;
|
||||
$progress-buffered-bg: rgba(red($gray), green($gray), blue($gray), .25);
|
||||
$progress-loading-size: 40px;
|
||||
$progress-loading-bg: rgba(0,0,0, .15);
|
||||
|
||||
@ -187,7 +187,7 @@ $bp-captions-large: 768px; // When captions jump to the larger font size
|
||||
@include clearfix();
|
||||
@include font-smoothing();
|
||||
position: relative;
|
||||
padding: ($control-spacing * 2) $control-spacing $control-spacing;
|
||||
padding: $control-spacing;
|
||||
background: $controls-bg;
|
||||
line-height: 1;
|
||||
text-align: center;
|
||||
@ -321,7 +321,7 @@ $bp-captions-large: 768px; // When captions jump to the larger font size
|
||||
// <progress> element
|
||||
&-progress {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 100%;
|
||||
left: 0;
|
||||
right: 0;
|
||||
width: 100%;
|
||||
@ -557,6 +557,17 @@ $bp-captions-large: 768px; // When captions jump to the larger font size
|
||||
left: 0;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
// Hide controls when playing in full screen
|
||||
&.fullscreen-hide-controls.playing .player-controls {
|
||||
transform: translateY(100%) translateY($control-spacing / 2);
|
||||
transition: transform .3s 1s ease;
|
||||
|
||||
&.hover {
|
||||
transform: translateY(0);
|
||||
transition-delay: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Change icons on state change
|
||||
|
Reference in New Issue
Block a user