Merge branch 'master' into develop

# Conflicts:
#	demo/index.html
#	dist/plyr.js
This commit is contained in:
Sam Potts 2016-11-06 15:55:55 +11:00
commit bae04a492a
5 changed files with 83 additions and 22 deletions

View File

@ -1,5 +1,9 @@
# Changelog
## v2.0.10
- Added seek event fixes for Vimeo and YouTube (fixes #409)
- Added support for embed URLs rather than ID only (fixes #345)
## v2.0.9
- Temporary patch for the YouTube API issues with `getDuration()` (relates to #374)

4
dist/plyr.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"name": "plyr",
"version": "2.0.9",
"version": "2.0.10",
"description": "A simple, accessible and customizable HTML5, YouTube and Vimeo media player",
"homepage": "http://plyr.io",
"main": "src/js/plyr.js",

View File

@ -30,11 +30,21 @@ Oh and yes, it works with Bootstrap.
## Changelog
Check out the [changelog](changelog.md) to see what's new with Plyr.
## Planned Development
- Playback speed
## Features currently being developed
- Playback speed selection
- Quality selection
- Caption language selection
- AirPlay
- Picture in Picture (MacOS Sierra + Safari)
[more info](https://github.com/Selz/plyr/issues?q=is%3Aissue+is%3Aopen+label%3A%22In+Development%22)
## Planned features
- Playlists
- Multiple language captions (with selection)
- Google cast
- Facebook video support
- Wistia video support
- YouTube and Vimeo audio support
- Audio captions
...and whatever else has been raised in [issues](https://github.com/Selz/plyr/issues)
@ -106,10 +116,13 @@ For YouTube and Vimeo, Plyr uses the standard YouTube API markup (an empty `<div
<div data-type="youtube" data-video-id="bTqVqk7FSmY"></div>
```
Note: `data-video-id` value can now be the ID or URL for the video. This attribute name will change in a future release to reflect this change.
#### Vimeo embed
```html
<div data-type="vimeo" data-video-id="143418951"></div>
```
Note: `data-video-id` value can now be the ID or URL for the video. This attribute name will change in a future release to reflect this change.
### JavaScript
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).
@ -122,7 +135,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:
```html
<script src="https://cdn.plyr.io/2.0.9/plyr.js"></script>
<script src="https://cdn.plyr.io/2.0.10/plyr.js"></script>
```
### CSS
@ -135,11 +148,11 @@ Include the `plyr.css` stylsheet into your `<head>`
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/2.0.9/plyr.css">
<link rel="stylesheet" href="https://cdn.plyr.io/2.0.10/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/2.0.9/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/2.0.10/plyr.svg`.
## Advanced
@ -687,6 +700,8 @@ player.source({
});
```
Note: `src` can be the video ID or URL
Vimeo example
```javascript
@ -700,7 +715,9 @@ player.source({
});
```
Some more details on the object parameters
Note: `src` can be the video ID or URL
More details on the object parameters
<table class="table" width="100%">
<thead>
@ -724,7 +741,7 @@ Some more details on the object parameters
<tr>
<td><code>sources</code></td>
<td>Array</td>
<td>This is an array of sources. <code>type</code> is optional for YouTube and Vimeo when specifying an array. For YouTube and Vimeo media, only the video ID must be passed as the source as shown above. The keys of this object are mapped directly to HTML attributes so more can be added to the object if required.</td>
<td>This is an array of sources. <code>type</code> is optional for YouTube and Vimeo when specifying an array. For YouTube and Vimeo media, the video ID or URL must be passed as the source as shown above. The keys of this object are mapped directly to HTML attributes so more can be added to the object if required.</td>
</tr>
<tr>
<td><code>poster</code></td>
@ -787,7 +804,7 @@ These events also bubble up the DOM. The event target will be the container elem
<tr>
<td><code>ended</code></td>
<td></td>
<td>Sent when playback completes.</td>
<td>Sent when playback completes. Note: with Vimeo this does not occur if `loop` is enabled.</td>
</tr>
<tr>
<td><code>error</code></td>
@ -831,12 +848,12 @@ These events also bubble up the DOM. The event target will be the container elem
</tr>
<tr>
<td><code>seeked</code></td>
<td></td>
<td></td>
<td>Sent when a seek operation completes.</td>
</tr>
<tr>
<td><code>seeking</code></td>
<td></td>
<td></td>
<td>Sent when a seek operation begins.</td>
</tr>
<tr>

View File

@ -1,6 +1,6 @@
// ==========================================================================
// Plyr
// plyr.js v2.0.9
// plyr.js v2.0.10
// https://github.com/selz/plyr
// License: The MIT License (MIT)
// ==========================================================================
@ -45,7 +45,7 @@
displayDuration: true,
loadSprite: true,
iconPrefix: 'plyr',
iconUrl: 'https://cdn.plyr.io/2.0.9/plyr.svg',
iconUrl: 'https://cdn.plyr.io/2.0.10/plyr.svg',
clickToPlay: true,
hideControls: true,
showPosterOnEnd: false,
@ -190,7 +190,7 @@
speed: null
},
// Events to watch on HTML5 media elements
events: ['ready', 'ended', 'progress', 'stalled', 'playing', 'waiting', 'canplay', 'canplaythrough', 'loadstart', 'loadeddata', 'loadedmetadata', 'timeupdate', 'volumechange', 'play', 'pause', 'error', 'seeking', 'emptied'],
events: ['ready', 'ended', 'progress', 'stalled', 'playing', 'waiting', 'canplay', 'canplaythrough', 'loadstart', 'loadeddata', 'loadedmetadata', 'timeupdate', 'volumechange', 'play', 'pause', 'error', 'seeking', 'seeked', 'emptied'],
// Logging
logPrefix: '[Plyr]'
};
@ -576,6 +576,18 @@
}
};
// Parse YouTube ID from url
function _parseYouTubeId(url) {
var regex = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/;
return (url.match(regex)) ? RegExp.$2 : url;
}
// Parse Vimeo ID from url
function _parseVimeoId(url) {
var regex = /^.*(vimeo.com\/|video\/)(\d+).*/;
return (url.match(regex)) ? RegExp.$2 : url;
}
// Fullscreen API
var _fullscreen;
(function() {
@ -1688,9 +1700,23 @@
// Setup YouTube/Vimeo
function _setupEmbed() {
var container = document.createElement('div'),
mediaId = plyr.embedId,
mediaId,
id = plyr.type + '-' + Math.floor(Math.random() * (10000));
// Parse IDs from URLs if supplied
switch (plyr.type) {
case 'youtube':
mediaId = _parseYouTubeId(plyr.embedId);
break;
case 'vimeo':
mediaId = _parseVimeoId(plyr.embedId);
break;
default:
mediaId = plyr.embedId;
}
// Remove old containers
var containers = _getElements('[id^="' + plyr.type + '-"]');
for (var i = containers.length - 1; i >= 0; i--) {
@ -1907,6 +1933,12 @@
case 1:
plyr.media.paused = false;
// If we were seeking, fire seeked event
if (plyr.media.seeking) {
_triggerEvent(plyr.media, 'seeked');
}
plyr.media.seeking = false;
_triggerEvent(plyr.media, 'play');
_triggerEvent(plyr.media, 'playing');
@ -2031,6 +2063,12 @@
}
});
plyr.embed.on('seeked', function() {
plyr.media.seeking = false;
_triggerEvent(plyr.media, 'seeked');
_triggerEvent(plyr.media, 'play');
});
plyr.embed.on('ended', function() {
plyr.media.paused = true;
_triggerEvent(plyr.media, 'ended');
@ -2222,7 +2260,6 @@
// Embeds
if (_inArray(config.types.embed, plyr.type)) {
// YouTube
switch(plyr.type) {
case 'youtube':
plyr.embed.seekTo(targetTime);
@ -2242,11 +2279,14 @@
_pause();
}
// Trigger timeupdate for embeds
// Trigger timeupdate
_triggerEvent(plyr.media, 'timeupdate');
// Set seeking flag
plyr.media.seeking = true;
// Trigger seeking
_triggerEvent(plyr.media, 'seeking');
}
// Logging