Compare commits

...

19 Commits

Author SHA1 Message Date
57ad124ce8 v1.8.9 2016-07-21 21:25:27 +10:00
a85d45d2e5 Fix for fullscreen not being defined (Fixes #295) 2016-07-21 21:21:10 +10:00
a6f57fc034 Fix for multiline captions (Fixes #314) 2016-07-21 21:15:44 +10:00
04c9653b86 Merge branch 'master' of https://github.com/Selz/plyr 2016-07-21 21:14:29 +10:00
b8cdc71001 Clean up of type checks and fix for _restart() (Fixes #315) 2016-07-21 21:14:22 +10:00
277ebf0fd1 Merge pull request #312 from dpschen/patch-1
Add kirby-plyrtag
2016-07-14 22:03:50 +10:00
7682d998e7 Add kirby-plyrtag
Added a Kirby cms kirbytag https://getkirby.com/
2016-07-14 12:52:28 +02:00
05b9b9a831 Fix for MEDIA_ERR_SRC_NOT_SUPPORTED when calling .source() API method 2016-07-14 17:13:37 +10:00
eee699cec6 Version bump 2016-07-10 20:59:42 +10:00
3c9e9862d8 Added getCurrentTime API method (fixes #292) 2016-07-10 20:58:19 +10:00
39dc651a9d Fix for !hideControls on touch devices (fixes #303) 2016-07-10 20:50:55 +10:00
4effda125a Merge branch 'master' of https://github.com/Selz/plyr 2016-07-10 20:45:58 +10:00
bf9de231d8 Styling minor tweaks 2016-07-10 20:45:54 +10:00
ef12332505 Update readme.md 2016-06-29 16:23:38 +10:00
1b735f1727 Update readme.md 2016-06-26 22:21:19 +10:00
7f7ecf852e Line height fix 2016-06-26 09:07:42 +10:00
931672895f Reverted font size change 2016-06-26 09:04:38 +10:00
0952bc8239 Built JS 2016-06-26 08:45:06 +10:00
7e7508ca82 Fixed overflow issues (fixes #286) 2016-06-26 08:34:36 +10:00
13 changed files with 269 additions and 218 deletions

View File

@ -1,9 +1,28 @@
# Changelog # Changelog
# v1.8.4 ## 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 - Fix for large play button on small videos
# v1.8.3 ## v1.8.3
- Disabled iPad support for YouTube and Vimeo due to iOS limitations with iFrame playback - Disabled iPad support for YouTube and Vimeo due to iOS limitations with iFrame playback
- Fixed IE11 icon loading (fixes #269) - Fixed IE11 icon loading (fixes #269)
- Updated screenshot (fixes #281) - Updated screenshot (fixes #281)
@ -12,10 +31,10 @@
- Added HLS, Shaka and dash.js examples (see #235 for more) - Added HLS, Shaka and dash.js examples (see #235 for more)
- Improvements for controls hiding and showing on touch devices - Improvements for controls hiding and showing on touch devices
# v1.8.2 ## v1.8.2
- Fixed event bubbling - Fixed event bubbling
# v1.8.1 ## v1.8.1
- Fixed inaccurate log message - Fixed inaccurate log message
# v1.8.0 # v1.8.0

2
demo/dist/demo.css vendored

File diff suppressed because one or more lines are too long

View File

@ -8,78 +8,78 @@
// General functions // General functions
;(function() { ;(function() {
document.body.addEventListener('ready', function(event) { console.log(event); }); document.body.addEventListener('ready', function(event) { console.log(event); });
// Setup the player
var instances = plyr.setup({
debug: true,
title: 'Video demo',
iconUrl: '../dist/plyr.svg',
tooltips: {
controls: true
},
captions: {
defaultActive: true
}
});
plyr.loadSprite('dist/demo.svg');
// Setup the player // Plyr returns an array regardless
var instances = plyr.setup({ var player = instances[0].plyr;
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 // Setup type toggle
var player = instances[0].plyr; 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);
// Setup type toggle // Bind to each button
var buttons = document.querySelectorAll('[data-source]'), for (var i = buttons.length - 1; i >= 0; i--) {
types = { buttons[i].addEventListener('click', function() {
video: 'video', var type = this.getAttribute('data-source');
audio: 'audio',
youtube: 'youtube',
vimeo: 'vimeo'
},
currentType = window.location.hash.replace('#', ''),
historySupport = (window.history && window.history.pushState);
// Bind to each button newSource(type);
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);
}
});
}
if (historySupport) { // List for backwards/forwards
history.pushState({ 'type': type }, '', '#' + type); window.addEventListener('popstate', function(event) {
} if(event.state && 'type' in event.state) {
}); newSource(event.state.type);
} }
});
// List for backwards/forwards // On load
window.addEventListener('popstate', function(event) { if(historySupport) {
if(event.state && 'type' in event.state) { var video = !currentType.length;
newSource(event.state.type);
}
});
// On load // If there's no current type set, assume video
if(historySupport) { if(video) {
var video = !currentType.length; currentType = types.video;
}
// If there's no current type set, assume video // Replace current history state
if(video) { if(currentType in types) {
currentType = types.video; history.replaceState({ 'type': currentType }, '', (video ? '' : '#' + currentType));
} }
// Replace current history state // If it's not video, load the source
if(currentType in types) { if(currentType !== types.video) {
history.replaceState({ 'type': currentType }, '', (video ? '' : '#' + currentType)); newSource(currentType, true);
} }
}
// If it's not video, load the source // Toggle class on an element
if(currentType !== types.video) { function toggleClass(element, className, state) {
newSource(currentType, true);
}
}
// Toggle class on an element
function toggleClass(element, className, state) {
if (element) { if (element) {
if (element.classList) { if (element.classList) {
element.classList[state ? 'add' : 'remove'](className); element.classList[state ? 'add' : 'remove'](className);
@ -91,95 +91,95 @@
} }
} }
// Set a new source // Set a new source
function newSource(type, init) { function newSource(type, init) {
// Bail if new type isn't known, it's the current type, or current type is empty (video is default) and new type is video // Bail if new type isn't known, it's the current type, or current type is empty (video is default) and new type is video
if(!(type in types) || (!init && type == currentType) || (!currentType.length && type == types.video)) { if(!(type in types) || (!init && type == currentType) || (!currentType.length && type == types.video)) {
return; return;
} }
switch(type) { switch(type) {
case types.video: case types.video:
player.source({ player.source({
type: 'video', type: 'video',
title: 'View From A Blue Moon', title: 'View From A Blue Moon',
sources: [{ sources: [{
src: 'https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.mp4', src: 'https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.mp4',
type: 'video/mp4' type: 'video/mp4'
}, },
{ {
src: 'https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.webm', src: 'https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.webm',
type: 'video/webm' type: 'video/webm'
}], }],
poster: 'https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.jpg', poster: 'https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.jpg',
tracks: [{ tracks: [{
kind: 'captions', kind: 'captions',
label: 'English', label: 'English',
srclang:'en', srclang:'en',
src: 'https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.en.vtt', src: 'https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.en.vtt',
default: true default: true
}] }]
}); });
break; break;
case types.audio: case types.audio:
player.source({ player.source({
type: 'audio', type: 'audio',
title: 'Kishi Bashi – “It All Began With A Burst”', title: 'Kishi Bashi – “It All Began With A Burst”',
sources: [{ sources: [{
src: 'https://cdn.selz.com/plyr/1.5/Kishi_Bashi_-_It_All_Began_With_a_Burst.mp3', src: 'https://cdn.selz.com/plyr/1.5/Kishi_Bashi_-_It_All_Began_With_a_Burst.mp3',
type: 'audio/mp3' type: 'audio/mp3'
}, },
{ {
src: 'https://cdn.selz.com/plyr/1.5/Kishi_Bashi_-_It_All_Began_With_a_Burst.ogg', src: 'https://cdn.selz.com/plyr/1.5/Kishi_Bashi_-_It_All_Began_With_a_Burst.ogg',
type: 'audio/ogg' type: 'audio/ogg'
}] }]
}); });
break; break;
case types.youtube: case types.youtube:
player.source({ player.source({
type: 'video', type: 'video',
title: 'View From A Blue Moon', title: 'View From A Blue Moon',
sources: [{ sources: [{
src: 'bTqVqk7FSmY', src: 'bTqVqk7FSmY',
type: 'youtube' type: 'youtube'
}] }]
}); });
break; break;
case types.vimeo: case types.vimeo:
player.source({ player.source({
type: 'video', type: 'video',
title: 'View From A Blue Moon', title: 'View From A Blue Moon',
sources: [{ sources: [{
src: '143418951', src: '143418951',
type: 'vimeo' type: 'vimeo'
}] }]
}); });
break; break;
} }
// Set the current type for next time // Set the current type for next time
currentType = type; currentType = type;
// Remove active classes // Remove active classes
for (var x = buttons.length - 1; x >= 0; x--) { for (var x = buttons.length - 1; x >= 0; x--) {
toggleClass(buttons[x].parentElement, 'active', false); toggleClass(buttons[x].parentElement, 'active', false);
} }
// Set active on parent // Set active on parent
toggleClass(document.querySelector('[data-source="'+ type +'"]').parentElement, 'active', true); toggleClass(document.querySelector('[data-source="'+ type +'"]').parentElement, 'active', true);
} }
})(); })();
// Google analytics // Google analytics
// For demo site (http://[www.]plyr.io) only // For demo site (http://[www.]plyr.io) only
if(document.domain.indexOf('plyr.io') > -1) { if(document.domain.indexOf('plyr.io') > -1) {
(function(i,s,o,g,r,a,m){i.GoogleAnalyticsObject=r;i[r]=i[r]||function(){ (function(i,s,o,g,r,a,m){i.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), (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) 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'); })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-40881672-11', 'auto'); ga('create', 'UA-40881672-11', 'auto');
ga('send', 'pageview'); ga('send', 'pageview');
} }

View File

@ -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;

2
dist/plyr.css vendored

File diff suppressed because one or more lines are too long

4
dist/plyr.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{ {
"name": "plyr", "name": "plyr",
"version": "1.8.4", "version": "1.8.9",
"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",

View File

@ -41,13 +41,14 @@ If you have any cool ideas or features, please let me know by [creating an issue
## CMS plugins ## CMS plugins
### [WordPress](https://wordpress.org) ### [WordPress](https://wordpress.org/plugins/plyr/)
Created and maintained by Ryan Anthony Drake ([@iamryandrake](https://github.com/iamryandrake)) Created and maintained by Ryan Anthony Drake ([@iamryandrake](https://github.com/iamryandrake))
[Plyr on WordPress](https://wordpress.org/plugins/plyr/)
### [Neos](https://www.neos.io/) ### [Neos](https://packagist.org/packages/jonnitto/plyr)
Created and maintained by Jon Uhlmann ([@jonnitto](https://github.com/jonnitto)) Created and maintained by Jon Uhlmann ([@jonnitto](https://github.com/jonnitto))
[Plyr.io for Neos.io](https://packagist.org/packages/jonnitto/plyr)
### [Kirby](https://github.com/dpschen/kirby-plyrtag)
Created and maintained by Dominik Pschenitschni ([@dpschen](https://github.com/dpschen))
## Using package managers ## Using package managers
You can grab the source using one of the following package managers. You can grab the source using one of the following package managers.
@ -120,7 +121,7 @@ Include the `plyr.js` script before the closing `</body>` tag and then call `ply
If you want to use our CDN for the JavaScript, you can use the following: If you want to use our CDN for the JavaScript, you can use the following:
```html ```html
<script src="https://cdn.plyr.io/1.8.4/plyr.js"></script> <script src="https://cdn.plyr.io/1.8.9/plyr.js"></script>
``` ```
### CSS ### CSS
@ -133,16 +134,18 @@ Include the `plyr.css` stylsheet into your `<head>`
If you want to use our CDN for the default CSS, you can use the following: If you want to use our CDN for the default CSS, you can use the following:
```html ```html
<link rel="stylesheet" href="https://cdn.plyr.io/1.8.4/plyr.css"> <link rel="stylesheet" href="https://cdn.plyr.io/1.8.9/plyr.css">
``` ```
### SVG Sprite ### SVG Sprite
The SVG sprite is loaded automatically from our CDN. To change this, see the [#options](Options) below. For reference, the CDN hosted SVG sprite can be found at `https://cdn.plyr.io/1.8.4/plyr.svg`. 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.9/plyr.svg`.
## Advanced ## Advanced
### LESS & SASS/SCSS ### LESS & SASS/SCSS
You can use `plyr.less` or `plyr.scss` file included in `/src` as part of your build and change variables to suit your design. The 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. 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 icons used in the Plyr controls are loaded in an SVG sprite. The sprite is automatically loaded from our CDN by default. If you already have an icon build system in place, you can include the source plyr icons (see `/src/sprite` for source icons). The icons used in the Plyr controls are loaded in an SVG sprite. The sprite is automatically loaded from our CDN by default. If you already have an icon build system in place, you can include the source plyr icons (see `/src/sprite` for source icons).
@ -535,6 +538,11 @@ Here's a list of the methods supported:
<td>&mdash;</td> <td>&mdash;</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>&mdash;</td>
<td>Will return a float with the current time in seconds.</td>
</tr>
</tbody> </tbody>
</table> </table>

View File

@ -1,6 +1,6 @@
// ========================================================================== // ==========================================================================
// Plyr // Plyr
// plyr.js v1.8.4 // plyr.js v1.8.9
// https://github.com/selz/plyr // https://github.com/selz/plyr
// License: The MIT License (MIT) // License: The MIT License (MIT)
// ========================================================================== // ==========================================================================
@ -44,7 +44,7 @@
displayDuration: true, displayDuration: true,
loadSprite: true, loadSprite: true,
iconPrefix: 'plyr', iconPrefix: 'plyr',
iconUrl: 'https://cdn.plyr.io/1.8.4/plyr.svg', iconUrl: 'https://cdn.plyr.io/1.8.9/plyr.svg',
clickToPlay: true, clickToPlay: true,
hideControls: true, hideControls: true,
showPosterOnEnd: false, showPosterOnEnd: false,
@ -191,7 +191,7 @@
if ((navigator.appVersion.indexOf('Windows NT') !== -1) && (navigator.appVersion.indexOf('rv:11') !== -1)) { if ((navigator.appVersion.indexOf('Windows NT') !== -1) && (navigator.appVersion.indexOf('rv:11') !== -1)) {
isIE = true; isIE = true;
name = 'IE'; name = 'IE';
fullVersion = '11;'; fullVersion = '11';
} }
// MSIE // MSIE
else if ((verOffset = ua.indexOf('MSIE')) !== -1) { else if ((verOffset = ua.indexOf('MSIE')) !== -1) {
@ -376,7 +376,7 @@
// Set attributes // Set attributes
function _setAttributes(element, attributes) { function _setAttributes(element, attributes) {
for (var key in attributes) { for (var key in attributes) {
element.setAttribute(key, (typeof attributes[key] === 'boolean' && attributes[key]) ? '' : attributes[key]); element.setAttribute(key, (_is.boolean(attributes[key]) && attributes[key]) ? '' : attributes[key]);
} }
} }
@ -464,7 +464,7 @@
// Whether the listener is a capturing listener or not // Whether the listener is a capturing listener or not
// Default to false // Default to false
if (typeof useCapture !== 'boolean') { if (!_is.boolean(useCapture)) {
useCapture = false; useCapture = false;
} }
@ -492,7 +492,7 @@
} }
// Default bubbles to false // Default bubbles to false
if (typeof bubbles !== 'boolean') { if (!_is.boolean(bubbles)) {
bubbles = false; bubbles = false;
} }
@ -515,7 +515,7 @@
} }
// Get state // Get state
state = (typeof state === 'boolean' ? state : !target.getAttribute('aria-pressed')); state = (_is.boolean(state) ? state : !target.getAttribute('aria-pressed'));
// Set the attribute on target // Set the attribute on target
target.setAttribute('aria-pressed', state); target.setAttribute('aria-pressed', state);
@ -570,6 +570,28 @@
return destination; return destination;
} }
// Check variable types
var _is = {
object: function(input) {
return input !== null && typeof(input) === 'object' && input.constructor === Object;
},
array: function(input) {
return input !== null && typeof(input) === 'object' && input.constructor === Array;
},
number: function(input) {
return typeof(input) === 'number' && !isNaN(input - 0) || (typeof input == 'object' && input.constructor === Number);
},
string: function(input) {
return typeof input === 'string' || (typeof input == 'object' && input.constructor === String);
},
boolean: function(input) {
return typeof input === 'boolean';
},
undefined: function(input) {
return typeof input === 'undefined';
}
};
// Fullscreen API // Fullscreen API
function _fullscreen() { function _fullscreen() {
var fullscreen = { var fullscreen = {
@ -584,7 +606,7 @@
browserPrefixes = 'webkit moz o ms khtml'.split(' '); browserPrefixes = 'webkit moz o ms khtml'.split(' ');
// Check for native support // Check for native support
if (typeof document.cancelFullScreen !== 'undefined') { if (!_is.undefined(document.cancelFullScreen)) {
fullscreen.supportsFullScreen = true; fullscreen.supportsFullScreen = true;
} }
else { else {
@ -592,12 +614,12 @@
for (var i = 0, il = browserPrefixes.length; i < il; i++ ) { for (var i = 0, il = browserPrefixes.length; i < il; i++ ) {
fullscreen.prefix = browserPrefixes[i]; fullscreen.prefix = browserPrefixes[i];
if (typeof document[fullscreen.prefix + 'CancelFullScreen'] !== 'undefined') { if (!_is.undefined(document[fullscreen.prefix + 'CancelFullScreen'])) {
fullscreen.supportsFullScreen = true; fullscreen.supportsFullScreen = true;
break; break;
} }
// Special case for MS (when isn't it?) // Special case for MS (when isn't it?)
else if (typeof document.msExitFullscreen !== 'undefined' && document.msFullscreenEnabled) { else if (!_is.undefined(document.msExitFullscreen) && document.msFullscreenEnabled) {
fullscreen.prefix = 'ms'; fullscreen.prefix = 'ms';
fullscreen.supportsFullScreen = true; fullscreen.supportsFullScreen = true;
break; break;
@ -612,7 +634,7 @@
fullscreen.fullScreenEventName = (fullscreen.prefix == 'ms' ? 'MSFullscreenChange' : fullscreen.prefix + 'fullscreenchange'); fullscreen.fullScreenEventName = (fullscreen.prefix == 'ms' ? 'MSFullscreenChange' : fullscreen.prefix + 'fullscreenchange');
fullscreen.isFullScreen = function(element) { fullscreen.isFullScreen = function(element) {
if (typeof element === 'undefined') { if (_is.undefined(element)) {
element = document.body; element = document.body;
} }
switch (this.prefix) { switch (this.prefix) {
@ -625,7 +647,7 @@
} }
}; };
fullscreen.requestFullScreen = function(element) { fullscreen.requestFullScreen = function(element) {
if (typeof element === 'undefined') { if (_is.undefined(element)) {
element = document.body; element = document.body;
} }
return (this.prefix === '') ? element.requestFullScreen() : element[this.prefix + (this.prefix == 'ms' ? 'RequestFullscreen' : 'RequestFullScreen')](); return (this.prefix === '') ? element.requestFullScreen() : element[this.prefix + (this.prefix == 'ms' ? 'RequestFullscreen' : 'RequestFullScreen')]();
@ -878,7 +900,9 @@
} }
// Toggle state // Toggle state
_toggleState(plyr.buttons.fullscreen, false); if (plyr.buttons && plyr.buttons.fullscreen) {
_toggleState(plyr.buttons.fullscreen, false);
}
// Setup focus trap // Setup focus trap
_focusTrap(); _focusTrap();
@ -1041,12 +1065,12 @@
container.innerHTML = ''; container.innerHTML = '';
// Default to empty // Default to empty
if (typeof caption === 'undefined') { if (_is.undefined(caption)) {
caption = ''; caption = '';
} }
// Set the span content // Set the span content
if (typeof caption === 'string') { if (_is.undefined(caption)) {
content.innerHTML = caption.trim(); content.innerHTML = caption.trim();
} }
else { else {
@ -1106,7 +1130,7 @@
// Check time is a number, if not use currentTime // Check time is a number, if not use currentTime
// IE has a bug where currentTime doesn't go to 0 // IE has a bug where currentTime doesn't go to 0
// https://twitter.com/Sam_Potts/status/573715746506731521 // https://twitter.com/Sam_Potts/status/573715746506731521
time = typeof time === 'number' ? time : plyr.media.currentTime; time = _is.number(time) ? time : plyr.media.currentTime;
// If there's no subs available, bail // If there's no subs available, bail
if (!plyr.captions[plyr.subcount]) { if (!plyr.captions[plyr.subcount]) {
@ -1197,7 +1221,7 @@
// Add elements to HTML5 media (source, tracks, etc) // Add elements to HTML5 media (source, tracks, etc)
function _insertChildElements(type, attributes) { function _insertChildElements(type, attributes) {
if (typeof attributes === 'string') { if (_is.string(attributes)) {
_insertElement(type, plyr.media, { src: attributes }); _insertElement(type, plyr.media, { src: attributes });
} }
else if (attributes.constructor === Array) { else if (attributes.constructor === Array) {
@ -1247,7 +1271,7 @@
if (config.selectors.controls.container !== null) { if (config.selectors.controls.container !== null) {
container = config.selectors.controls.container; container = config.selectors.controls.container;
if (typeof selector === 'string') { if (_is.string(selector)) {
container = document.querySelector(container); container = document.querySelector(container);
} }
} }
@ -1350,7 +1374,7 @@
var label = config.i18n.play; var label = config.i18n.play;
// If there's a media title set, use that for the label // If there's a media title set, use that for the label
if (typeof(config.title) !== 'undefined' && config.title.length) { if (!_is.undefined(config.title) && config.title.length) {
label += ', ' + config.title; label += ', ' + config.title;
} }
@ -1443,7 +1467,7 @@
container.setAttribute('id', id); container.setAttribute('id', id);
// Setup API // Setup API
if (typeof YT === 'object') { if (_is.object(YT)) {
_youTubeReady(mediaId, container); _youTubeReady(mediaId, container);
} }
else { else {
@ -1878,7 +1902,7 @@
// Rewind // Rewind
function _rewind(seekTime) { function _rewind(seekTime) {
// Use default if needed // Use default if needed
if (typeof seekTime !== 'number') { if (!_is.number(seekTime)) {
seekTime = config.seekTime; seekTime = config.seekTime;
} }
_seek(plyr.media.currentTime - seekTime); _seek(plyr.media.currentTime - seekTime);
@ -1887,7 +1911,7 @@
// Fast forward // Fast forward
function _forward(seekTime) { function _forward(seekTime) {
// Use default if needed // Use default if needed
if (typeof seekTime !== 'number') { if (!_is.number(seekTime)) {
seekTime = config.seekTime; seekTime = config.seekTime;
} }
_seek(plyr.media.currentTime + seekTime); _seek(plyr.media.currentTime + seekTime);
@ -1901,11 +1925,11 @@
duration = _getDuration(); duration = _getDuration();
// Explicit position // Explicit position
if (typeof input === 'number') { if (_is.number(input)) {
targetTime = input; targetTime = input;
} }
// Event // Event
else if (input.type && _inArray(['input', 'change'], input.type)) { else if (_is.object(input) && _inArray(['input', 'change'], input.type)) {
// It's the seek slider // It's the seek slider
// Seek to the selected time // Seek to the selected time
targetTime = ((input.target.value / input.target.max) * duration); targetTime = ((input.target.value / input.target.max) * duration);
@ -2060,7 +2084,9 @@
_focusTrap(plyr.isFullscreen); _focusTrap(plyr.isFullscreen);
// Set button state // Set button state
_toggleState(plyr.buttons.fullscreen, plyr.isFullscreen); if (plyr.buttons && plyr.buttons.fullscreen) {
_toggleState(plyr.buttons.fullscreen, plyr.isFullscreen);
}
// Trigger an event // Trigger an event
_triggerEvent(plyr.container, plyr.isFullscreen ? 'enterfullscreen' : 'exitfullscreen', true); _triggerEvent(plyr.container, plyr.isFullscreen ? 'enterfullscreen' : 'exitfullscreen', true);
@ -2082,7 +2108,7 @@
// Mute // Mute
function _toggleMute(muted) { function _toggleMute(muted) {
// If the method is called without parameter, toggle based on current value // If the method is called without parameter, toggle based on current value
if (typeof muted !== 'boolean') { if (!_is.boolean(muted)) {
muted = !plyr.media.muted; muted = !plyr.media.muted;
} }
@ -2125,7 +2151,7 @@
min = config.volumeMin; min = config.volumeMin;
// Use default if no value specified // Use default if no value specified
if (typeof volume === 'undefined') { if (_is.undefined(volume)) {
volume = config.volume; volume = config.volume;
if (config.storage.enabled && _storage().supported) { if (config.storage.enabled && _storage().supported) {
@ -2237,7 +2263,7 @@
} }
// If the method is called without parameter, toggle based on current value // If the method is called without parameter, toggle based on current value
if (typeof show !== 'boolean') { if (!_is.boolean(show)) {
show = (plyr.container.className.indexOf(config.classes.captions.active) === -1); show = (plyr.container.className.indexOf(config.classes.captions.active) === -1);
} }
@ -2307,7 +2333,7 @@
return _getPercentage(buffered.end(0), duration); return _getPercentage(buffered.end(0), duration);
} }
// YouTube returns between 0 and 1 // YouTube returns between 0 and 1
else if (typeof buffered === 'number') { else if (_is.number(buffered)) {
return (buffered * 100); return (buffered * 100);
} }
@ -2329,11 +2355,11 @@
} }
// Default to 0 // Default to 0
if (typeof value === 'undefined') { if (_is.undefined(value)) {
value = 0; value = 0;
} }
// Default to buffer or bail // Default to buffer or bail
if (typeof progress === 'undefined') { if (_is.undefined(progress)) {
if (plyr.progress && plyr.progress.buffer) { if (plyr.progress && plyr.progress.buffer) {
progress = plyr.progress.buffer; progress = plyr.progress.buffer;
} }
@ -2424,7 +2450,7 @@
// Update seek range and progress // Update seek range and progress
function _updateSeekDisplay(time) { function _updateSeekDisplay(time) {
// Default to 0 // Default to 0
if (typeof time !== 'number') { if (!_is.number(time)) {
time = 0; time = 0;
} }
@ -2501,7 +2527,7 @@
show = toggle; show = toggle;
// Default to false if no boolean // Default to false if no boolean
if (typeof toggle !== 'boolean') { if (!_is.boolean(toggle)) {
if (toggle && toggle.type) { if (toggle && toggle.type) {
// Is the enter fullscreen event // Is the enter fullscreen event
isEnterFullscreen = (toggle.type === 'enterfullscreen'); isEnterFullscreen = (toggle.type === 'enterfullscreen');
@ -2559,7 +2585,7 @@
// Add common function to retrieve media source // Add common function to retrieve media source
function _source(source) { function _source(source) {
// If not null or undefined, parse it // If not null or undefined, parse it
if (typeof source !== 'undefined') { if (!_is.undefined(source)) {
_updateSource(source); _updateSource(source);
return; return;
} }
@ -2594,7 +2620,7 @@
// Update source // Update source
// Sources are not checked for support so be careful // Sources are not checked for support so be careful
function _updateSource(source) { function _updateSource(source) {
if (typeof source === 'undefined' || !('sources' in source) || !source.sources.length) { if (!_is.object(source) || !('sources' in source) || !source.sources.length) {
_warn('Invalid source format'); _warn('Invalid source format');
return; return;
} }
@ -2671,7 +2697,7 @@
_prependChild(plyr.container, plyr.media); _prependChild(plyr.container, plyr.media);
// Autoplay the new source? // Autoplay the new source?
if (typeof source.autoplay !== 'undefined') { if (_is.boolean(source.autoplay)) {
config.autoplay = source.autoplay; config.autoplay = source.autoplay;
} }
@ -2979,8 +3005,8 @@
// On click play, pause ore restart // On click play, pause ore restart
_on(wrapper, 'click', function() { _on(wrapper, 'click', function() {
// Touch devices will just show controls // Touch devices will just show controls (if we're hiding controls)
if (plyr.browser.isTouch && !plyr.media.paused) { if (config.hideControls && plyr.browser.isTouch && !plyr.media.paused) {
return; return;
} }
@ -3023,9 +3049,8 @@
// Set blank video src attribute // Set blank video src attribute
// This is to prevent a MEDIA_ERR_SRC_NOT_SUPPORTED error // This is to prevent a MEDIA_ERR_SRC_NOT_SUPPORTED error
// Small mp4: https://github.com/mathiasbynens/small/blob/master/mp4.mp4
// Info: http://stackoverflow.com/questions/32231579/how-to-properly-dispose-of-an-html5-video-and-close-socket-or-connection // Info: http://stackoverflow.com/questions/32231579/how-to-properly-dispose-of-an-html5-video-and-close-socket-or-connection
plyr.media.setAttribute('src', 'data:video/mp4;base64,AAAAHGZ0eXBpc29tAAACAGlzb21pc28ybXA0MQAAAAhmcmVlAAAAGm1kYXQAAAGzABAHAAABthBgUYI9t+8AAAMNbW9vdgAAAGxtdmhkAAAAAMXMvvrFzL76AAAD6AAAACoAAQAAAQAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAABhpb2RzAAAAABCAgIAHAE/////+/wAAAiF0cmFrAAAAXHRraGQAAAAPxcy++sXMvvoAAAABAAAAAAAAACoAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAAAgAAAAIAAAAAAG9bWRpYQAAACBtZGhkAAAAAMXMvvrFzL76AAAAGAAAAAEVxwAAAAAALWhkbHIAAAAAAAAAAHZpZGUAAAAAAAAAAAAAAABWaWRlb0hhbmRsZXIAAAABaG1pbmYAAAAUdm1oZAAAAAEAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAAShzdGJsAAAAxHN0c2QAAAAAAAAAAQAAALRtcDR2AAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAgACABIAAAASAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGP//AAAAXmVzZHMAAAAAA4CAgE0AAQAEgICAPyARAAAAAAMNQAAAAAAFgICALQAAAbABAAABtYkTAAABAAAAASAAxI2IAMUARAEUQwAAAbJMYXZjNTMuMzUuMAaAgIABAgAAABhzdHRzAAAAAAAAAAEAAAABAAAAAQAAABxzdHNjAAAAAAAAAAEAAAABAAAAAQAAAAEAAAAUc3RzegAAAAAAAAASAAAAAQAAABRzdGNvAAAAAAAAAAEAAAAsAAAAYHVkdGEAAABYbWV0YQAAAAAAAAAhaGRscgAAAAAAAAAAbWRpcmFwcGwAAAAAAAAAAAAAAAAraWxzdAAAACOpdG9vAAAAG2RhdGEAAAABAAAAAExhdmY1My4yMS4x'); plyr.media.setAttribute('src', 'https://cdn.selz.com/plyr/blank.mp4');
// Load the new empty source // Load the new empty source
// This will cancel existing requests // This will cancel existing requests
@ -3264,7 +3289,8 @@
isFullscreen: function() { return plyr.isFullscreen || false; }, isFullscreen: function() { return plyr.isFullscreen || false; },
support: function(mimeType) { return _supportMime(plyr, mimeType); }, support: function(mimeType) { return _supportMime(plyr, mimeType); },
destroy: _destroy, destroy: _destroy,
restore: _init restore: _init,
getCurrentTime: function() { return plyr.media.currentTime; }
}; };
} }
@ -3273,7 +3299,7 @@
var x = new XMLHttpRequest(); var x = new XMLHttpRequest();
// If the id is set and sprite exists, bail // If the id is set and sprite exists, bail
if (typeof id === 'string' && document.querySelector('#' + id) !== null) { if (_is.string(id) && document.querySelector('#' + id) !== null) {
return; return;
} }
@ -3289,7 +3315,7 @@
x.onload = function() { x.onload = function() {
var c = document.createElement('div'); var c = document.createElement('div');
c.setAttribute('hidden', ''); c.setAttribute('hidden', '');
if (typeof id === 'string') { if (_is.string(id)) {
c.setAttribute('id', id); c.setAttribute('id', id);
} }
c.innerHTML = x.responseText; c.innerHTML = x.responseText;
@ -3347,7 +3373,7 @@
// Select the elements // Select the elements
// Assume elements is a NodeList by default // Assume elements is a NodeList by default
if (typeof targets === 'string') { if (_is.string(targets)) {
targets = document.querySelectorAll(targets); targets = document.querySelectorAll(targets);
} }
// Single HTMLElement passed // Single HTMLElement passed
@ -3355,9 +3381,9 @@
targets = [targets]; targets = [targets];
} }
// No selector passed, possibly options as first argument // No selector passed, possibly options as first argument
else if (!(targets instanceof NodeList) && typeof targets !== 'string') { else if (!(targets instanceof NodeList) && !_is.string(targets)) {
// If options are the first argument // If options are the first argument
if (typeof options === 'undefined' && typeof targets === 'object') { if (_is.undefined(options) && _is.object(targets)) {
options = targets; options = targets;
} }
@ -3451,7 +3477,7 @@
// https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent // https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent
(function () { (function () {
if (typeof window.CustomEvent === 'function') { if (typeof window.CustomEvent === 'function') {
return false; return;
} }
function CustomEvent(event, params) { function CustomEvent(event, params) {

View File

@ -19,8 +19,7 @@
position: relative; position: relative;
max-width: 100%; max-width: 100%;
min-width: 200px; min-width: 200px;
overflow: hidden; font-family: @plyr-font-family;
font-family: Avenir, "Avenir Next", "Helvetica Neue", "Segoe UI", Helvetica, Arial, sans-serif;
direction: ltr; direction: ltr;
& when (@plyr-border-box = true) { & when (@plyr-border-box = true) {
@ -226,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;
@ -354,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 {
@ -379,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;
@ -664,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 {

View File

@ -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;
@ -32,7 +33,6 @@
@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;

View File

@ -19,8 +19,7 @@
position: relative; position: relative;
max-width: 100%; max-width: 100%;
min-width: 200px; min-width: 200px;
overflow: hidden; font-family: $plyr-font-family;
font-family: Avenir, "Avenir Next", "Helvetica Neue", "Segoe UI", Helvetica, Arial, sans-serif;
direction: ltr; direction: ltr;
@if $plyr-border-box == true { @if $plyr-border-box == true {
@ -226,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;
@ -354,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 {
@ -379,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;
@ -663,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 {

View File

@ -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;
$plyr-font-size-small: 14px !default; $plyr-font-size-small: 14px !default;
$plyr-font-size-base: 16px !default; $plyr-font-size-base: 16px !default;
@ -33,7 +34,6 @@ $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;