Bug fixes and improvements
This commit is contained in:
parent
9e65b67bc1
commit
4d483bf66c
@ -29,5 +29,5 @@
|
||||
"type": "git",
|
||||
"url": "git://github.com/selz/plyr.git"
|
||||
},
|
||||
"license": "BSD"
|
||||
"license": "MIT"
|
||||
}
|
@ -1,5 +1,11 @@
|
||||
# Changelog
|
||||
|
||||
## v1.0.20
|
||||
- Default controls included (Fixes #45)
|
||||
- Volume changes on `input` as well as `change` (Fixes #43)
|
||||
- Fix for undefined Play text
|
||||
- License changed to MIT
|
||||
|
||||
## v1.0.19
|
||||
- Fixed firefox fullscreen issue (#38)
|
||||
|
||||
|
124
controls.md
124
controls.md
@ -1,8 +1,8 @@
|
||||
# Controls HTML
|
||||
|
||||
This is the markup that is rendered for the Plyr controls. The reason it's a separate option is to allow full customization of markup based on your needs. It's a pet hate of other libraries that use `<a href="#">` or `<span>`s as buttons!
|
||||
This is the markup that is rendered for the Plyr controls. You can use the default controls or provide a customized version of markup based on your needs.
|
||||
|
||||
The default Plyr setup uses a Hogan template. The reason being to allow for localization at a later date. Check out `controls.html` in `/src/templates` to get an idea of how the default html is structured. Alternatively just use the vanilla HTML below.
|
||||
The demo Plyr setup uses a Hogan template. This purely to allow for localization at a later date. Check out `controls.html` in `/src/templates` to get an idea of how the default html is structured. Alternatively check out the `plyr.js` source.
|
||||
|
||||
## Requirements
|
||||
|
||||
@ -15,67 +15,65 @@ You need to add several placeholders to your html template that are replaced whe
|
||||
|
||||
Currently all buttons and inputs need to be present for Plyr to work but later we'll make it more dynamic so if you omit a button or input, it'll still work.
|
||||
|
||||
## Vanilla HTML template
|
||||
## Default
|
||||
|
||||
You can of course, just specify vanilla HTML. Here's an example snippet:
|
||||
This is the default `html` option from `plyr.js`.
|
||||
|
||||
```html
|
||||
var controls = [
|
||||
'<div class="player-controls">',
|
||||
'<div class="player-progress">',
|
||||
'<progress class="player-progress-played" max="100" value="0">',
|
||||
'<span>0</span>% played',
|
||||
'</progress>',
|
||||
'<progress class="player-progress-buffer" max="100" value="0">',
|
||||
'<span>0</span>% buffered',
|
||||
'</progress>',
|
||||
'</div>',
|
||||
'<span class="player-controls-playback">',
|
||||
'<button type="button" data-player="restart">',
|
||||
'<svg><use xlink:href="#icon-refresh"></use></svg>',
|
||||
'<span class="sr-only">Restart</span>',
|
||||
'</button>',
|
||||
'<button type="button" data-player="rewind">',
|
||||
'<svg><use xlink:href="#icon-rewind"></use></svg>',
|
||||
'<span class="sr-only">Rewind <span class="player-seek-time">{seektime}</span> seconds</span>',
|
||||
'</button>',
|
||||
'<button type="button" data-player="play">',
|
||||
'<svg><use xlink:href="#icon-play"></use></svg>',
|
||||
'<span class="sr-only">Play</span>',
|
||||
'</button>',
|
||||
'<button type="button" data-player="pause">',
|
||||
'<svg><use xlink:href="#icon-pause"></use></svg>',
|
||||
'<span class="sr-only">Pause</span>',
|
||||
'</button>',
|
||||
'<button type="button" data-player="fast-forward">',
|
||||
'<svg><use xlink:href="#icon-fast-forward"></use></svg>',
|
||||
'<span class="sr-only">Fast forward <span class="player-seek-time">{seektime}</span> seconds</span>',
|
||||
'</button>',
|
||||
'<span class="player-time">',
|
||||
'<span class="sr-only">Time</span>',
|
||||
'<span class="player-duration">00:00</span>',
|
||||
'</span>',
|
||||
'</span>',
|
||||
'<span class="player-controls-sound">',
|
||||
'<input class="inverted sr-only" id="mute{id}" type="checkbox" data-player="mute">',
|
||||
'<label id="mute{id}" for="mute{id}">',
|
||||
'<svg class="icon-muted"><use xlink:href="#icon-muted"></use></svg>',
|
||||
'<svg><use xlink:href="#icon-sound"></use></svg>',
|
||||
'<span class="sr-only">Mute</span>',
|
||||
'</label>',
|
||||
'<label for="volume{id}" class="sr-only">Volume</label>',
|
||||
'<input id="volume{id}" class="player-volume" type="range" min="0" max="10" value="5" data-player="volume">',
|
||||
'<input class="sr-only" id="captions{id}" type="checkbox" data-player="captions">',
|
||||
'<label for="captions{id}">',
|
||||
'<svg><use xlink:href="#icon-bubble"></use></svg>',
|
||||
'<span class="sr-only">Captions</span>',
|
||||
'</label>',
|
||||
'<button type="button" data-player="fullscreen">',
|
||||
'<svg class="icon-exit-fullscreen"><use xlink:href="#icon-collapse"></use></svg>',
|
||||
'<svg><use xlink:href="#icon-expand"></use></svg>',
|
||||
'<span class="sr-only">Toggle fullscreen</span>',
|
||||
'</button>',
|
||||
'</span>',
|
||||
'</div>'
|
||||
].join("\n");
|
||||
```javascript
|
||||
["<div class='player-controls'>",
|
||||
"<div class='player-progress'>",
|
||||
"<progress class='player-progress-played' max='100' value='0'>",
|
||||
"<span>0</span>% played",
|
||||
"</progress>",
|
||||
"<progress class='player-progress-buffer' max='100' value='0'>",
|
||||
"<span>0</span>% buffered",
|
||||
"</progress>",
|
||||
"</div>",
|
||||
"<span class='player-controls-playback'>",
|
||||
"<button type='button' data-player='restart'>",
|
||||
"<svg><use xlink:href='#icon-refresh'></use></svg>",
|
||||
"<span class='sr-only'>Restart</span>",
|
||||
"</button>",
|
||||
"<button type='button' data-player='rewind'>",
|
||||
"<svg><use xlink:href='#icon-rewind'></use></svg>",
|
||||
"<span class='sr-only'>Rewind <span class='player-seek-time'>{seektime}</span> seconds</span>",
|
||||
"</button>",
|
||||
"<button type='button' data-player='play'>",
|
||||
"<svg><use xlink:href='#icon-play'></use></svg>",
|
||||
"<span class='sr-only'>Play</span>",
|
||||
"</button>",
|
||||
"<button type='button' data-player='pause'>",
|
||||
"<svg><use xlink:href='#icon-pause'></use></svg>",
|
||||
"<span class='sr-only'>Pause</span>",
|
||||
"</button>",
|
||||
"<button type='button' data-player='fast-forward'>",
|
||||
"<svg><use xlink:href='#icon-fast-forward'></use></svg>",
|
||||
"<span class='sr-only'>Fast forward <span class='player-seek-time'>{seektime}</span> seconds</span>",
|
||||
"</button>",
|
||||
"<span class='player-time'>",
|
||||
"<span class='sr-only'>Time</span>",
|
||||
"<span class='player-duration'>00:00</span>",
|
||||
"</span>",
|
||||
"</span>",
|
||||
"<span class='player-controls-sound'>",
|
||||
"<input class='inverted sr-only' id='mute{id}' type='checkbox' data-player='mute'>",
|
||||
"<label id='mute{id}' for='mute{id}'>",
|
||||
"<svg class='icon-muted'><use xlink:href='#icon-muted'></use></svg>",
|
||||
"<svg><use xlink:href='#icon-sound'></use></svg>",
|
||||
"<span class='sr-only'>Mute</span>",
|
||||
"</label>",
|
||||
"<label for='volume{id}' class='sr-only'>Volume</label>",
|
||||
"<input id='volume{id}' class='player-volume' type='range' min='0' max='10' value='5' data-player='volume'>",
|
||||
"<input class='sr-only' id='captions{id}' type='checkbox' data-player='captions'>",
|
||||
"<label for='captions{id}'>",
|
||||
"<svg><use xlink:href='#icon-bubble'></use></svg>",
|
||||
"<span class='sr-only'>Captions</span>",
|
||||
"</label>",
|
||||
"<button type='button' data-player='fullscreen'>",
|
||||
"<svg class='icon-exit-fullscreen'><use xlink:href='#icon-collapse'></use></svg>",
|
||||
"<svg><use xlink:href='#icon-expand'></use></svg>",
|
||||
"<span class='sr-only'>Toggle fullscreen</span>",
|
||||
"</button>",
|
||||
"</span>",
|
||||
"</div>"].join("\n");
|
||||
```
|
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.19/docs.css">
|
||||
<link rel="stylesheet" href="//cdn.plyr.io/1.0.20/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.19/plyr.css">
|
||||
<link rel="stylesheet" href="//cdn.plyr.io/1.0.20/plyr.css">
|
||||
|
||||
<!-- Docs styles -->
|
||||
<link rel="stylesheet" href="//cdn.plyr.io/1.0.19/docs.css">
|
||||
<link rel="stylesheet" href="//cdn.plyr.io/1.0.20/docs.css">
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
@ -67,13 +67,13 @@
|
||||
<!-- 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.19/sprite.svg");
|
||||
(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.20/sprite.svg");
|
||||
</script>
|
||||
|
||||
<!-- Plyr core script -->
|
||||
<script src="//cdn.plyr.io/1.0.19/plyr.js"></script>
|
||||
<script src="//cdn.plyr.io/1.0.20/plyr.js"></script>
|
||||
|
||||
<!-- Docs script -->
|
||||
<script src="//cdn.plyr.io/1.0.19/docs.js"></script>
|
||||
<script src="//cdn.plyr.io/1.0.20/docs.js"></script>
|
||||
</body>
|
||||
</html>
|
25
license.md
25
license.md
@ -1,12 +1,21 @@
|
||||
Copyright (c) 2015, Selz.com
|
||||
All rights reserved.
|
||||
The MIT License (MIT)
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
Copyright (c) 2015 Selz.com
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "plyr",
|
||||
"version": "1.0.19",
|
||||
"version": "1.0.20",
|
||||
"description": "A simple HTML5 media player using custom controls",
|
||||
"homepage": "http://plyr.io",
|
||||
"main": "gulpfile.js",
|
||||
@ -39,5 +39,5 @@
|
||||
"authors": [
|
||||
"Sam Potts <me@sampotts.me>"
|
||||
],
|
||||
"license": "BSD"
|
||||
"license": "MIT"
|
||||
}
|
||||
|
12
readme.md
12
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 4.8KB minified and gzipped.
|
||||
- **Lightweight** - just 5.3KB 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.
|
||||
@ -131,13 +131,15 @@ Much of the behaviour of the player is configurable when initialising the librar
|
||||
<script src="dist/plyr.js"></script>
|
||||
<script>
|
||||
plyr.setup({
|
||||
html: **your controls html**
|
||||
*options*
|
||||
});
|
||||
</script>
|
||||
```
|
||||
|
||||
#### Options
|
||||
|
||||
You can pass the following options to the setup method.
|
||||
|
||||
<table class="table" width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -157,8 +159,8 @@ plyr.setup({
|
||||
<tr>
|
||||
<td><code>html</code></td>
|
||||
<td>String</td>
|
||||
<td><code>—</code></td>
|
||||
<td>This is **required**. See <a href="controls.md">controls.md</a> for more info on how the html needs to be structured.</td>
|
||||
<td><code><a href="controls.md">See controls.md</a></code></td>
|
||||
<td>See <a href="controls.md">controls.md</a> for more info on how the html needs to be structured.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>debug</code></td>
|
||||
@ -360,4 +362,4 @@ Also these links helped created Plyr:
|
||||
- [Styling the `<progress>` element - hongkiat.com](http://www.hongkiat.com/blog/html5-progress-bar/)
|
||||
|
||||
## Copyright and License
|
||||
Copyright 2014, Selz.com under [the BSD license](license.md).
|
||||
[The MIT license](license.md).
|
@ -1,7 +1,8 @@
|
||||
// ==========================================================================
|
||||
// Plyr
|
||||
// plyr.js v1.0.19
|
||||
// plyr.js v1.0.20
|
||||
// https://github.com/sampotts/plyr
|
||||
// License: The MIT License (MIT)
|
||||
// ==========================================================================
|
||||
// Credits: http://paypal.github.io/accessible-html5-video-player/
|
||||
// ==========================================================================
|
||||
@ -67,7 +68,65 @@
|
||||
},
|
||||
storage: {
|
||||
enabled: true
|
||||
}
|
||||
},
|
||||
html: (function() {
|
||||
return ["<div class='player-controls'>",
|
||||
"<div class='player-progress'>",
|
||||
"<progress class='player-progress-played' max='100' value='0'>",
|
||||
"<span>0</span>% played",
|
||||
"</progress>",
|
||||
"<progress class='player-progress-buffer' max='100' value='0'>",
|
||||
"<span>0</span>% buffered",
|
||||
"</progress>",
|
||||
"</div>",
|
||||
"<span class='player-controls-playback'>",
|
||||
"<button type='button' data-player='restart'>",
|
||||
"<svg><use xlink:href='#icon-refresh'></use></svg>",
|
||||
"<span class='sr-only'>Restart</span>",
|
||||
"</button>",
|
||||
"<button type='button' data-player='rewind'>",
|
||||
"<svg><use xlink:href='#icon-rewind'></use></svg>",
|
||||
"<span class='sr-only'>Rewind <span class='player-seek-time'>{seektime}</span> seconds</span>",
|
||||
"</button>",
|
||||
"<button type='button' data-player='play'>",
|
||||
"<svg><use xlink:href='#icon-play'></use></svg>",
|
||||
"<span class='sr-only'>Play</span>",
|
||||
"</button>",
|
||||
"<button type='button' data-player='pause'>",
|
||||
"<svg><use xlink:href='#icon-pause'></use></svg>",
|
||||
"<span class='sr-only'>Pause</span>",
|
||||
"</button>",
|
||||
"<button type='button' data-player='fast-forward'>",
|
||||
"<svg><use xlink:href='#icon-fast-forward'></use></svg>",
|
||||
"<span class='sr-only'>Fast forward <span class='player-seek-time'>{seektime}</span> seconds</span>",
|
||||
"</button>",
|
||||
"<span class='player-time'>",
|
||||
"<span class='sr-only'>Time</span>",
|
||||
"<span class='player-duration'>00:00</span>",
|
||||
"</span>",
|
||||
"</span>",
|
||||
"<span class='player-controls-sound'>",
|
||||
"<input class='inverted sr-only' id='mute{id}' type='checkbox' data-player='mute'>",
|
||||
"<label id='mute{id}' for='mute{id}'>",
|
||||
"<svg class='icon-muted'><use xlink:href='#icon-muted'></use></svg>",
|
||||
"<svg><use xlink:href='#icon-sound'></use></svg>",
|
||||
"<span class='sr-only'>Mute</span>",
|
||||
"</label>",
|
||||
"<label for='volume{id}' class='sr-only'>Volume</label>",
|
||||
"<input id='volume{id}' class='player-volume' type='range' min='0' max='10' value='5' data-player='volume'>",
|
||||
"<input class='sr-only' id='captions{id}' type='checkbox' data-player='captions'>",
|
||||
"<label for='captions{id}'>",
|
||||
"<svg><use xlink:href='#icon-bubble'></use></svg>",
|
||||
"<span class='sr-only'>Captions</span>",
|
||||
"</label>",
|
||||
"<button type='button' data-player='fullscreen'>",
|
||||
"<svg class='icon-exit-fullscreen'><use xlink:href='#icon-collapse'></use></svg>",
|
||||
"<svg><use xlink:href='#icon-expand'></use></svg>",
|
||||
"<span class='sr-only'>Toggle fullscreen</span>",
|
||||
"</button>",
|
||||
"</span>",
|
||||
"</div>"].join("\n");
|
||||
})()
|
||||
};
|
||||
|
||||
// Debugging
|
||||
@ -489,11 +548,11 @@
|
||||
|
||||
// Setup aria attributes
|
||||
function _setupAria() {
|
||||
var label = player.buttons.play.innerText;
|
||||
var label = player.buttons.play.innerText || "Play";
|
||||
|
||||
// If there's a media title set, use that for the label
|
||||
if (typeof(config.title) !== "undefined" && config.title.length) {
|
||||
label = player.buttons.play.innerText + ", " + config.title;
|
||||
label += ", " + config.title;
|
||||
}
|
||||
|
||||
player.buttons.play.setAttribute("aria-label", label);
|
||||
@ -974,8 +1033,9 @@
|
||||
// Fast forward
|
||||
_on(player.buttons.forward, "click", _forward);
|
||||
|
||||
// Get the HTML5 range input element and append audio volume adjustment on change
|
||||
_on(player.volume, "change", function() {
|
||||
// Get the HTML5 range input element and append audio volume adjustment on change/input
|
||||
// IE10 doesn't support the "input" event so they have to wait for change
|
||||
_on(player.volume, "change input", function() {
|
||||
_setVolume(this.value);
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user