Fixed API method, added new methods (fixes #346, #351)

- Fixed `getCurrentTime()` method (fixes #351)
- Added `getVolume()` , `isMuted()` and `getDuration()` API methods (fixes #346)
This commit is contained in:
Sam 2016-08-29 23:36:43 +10:00
parent 15fd7041ab
commit 435b5c74bf
5 changed files with 40 additions and 16 deletions

View File

@ -1,5 +1,9 @@
# Changelog # Changelog
## v2.0.7
- Fixed `getCurrentTime()` method (fixes #351)
- Added `getVolume()` , `isMuted()` and `getDuration()` API methods (fixes #346)
## v2.0.6 ## v2.0.6
- Fixed merge issue with `Updated define to work with AMD imports #326` PR - Fixed merge issue with `Updated define to work with AMD imports #326` PR
- Code formatting - Code formatting

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": "2.0.6", "version": "2.0.7",
"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

@ -122,7 +122,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/2.0.6/plyr.js"></script> <script src="https://cdn.plyr.io/2.0.7/plyr.js"></script>
``` ```
### CSS ### CSS
@ -135,11 +135,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: 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/2.0.6/plyr.css"> <link rel="stylesheet" href="https://cdn.plyr.io/2.0.7/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/2.0.6/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.7/plyr.svg`.
## Advanced ## Advanced
@ -529,6 +529,26 @@ Here's a list of the methods supported:
<td>Number</td> <td>Number</td>
<td>Seeks the media to the provided parameter, time in seconds.</td> <td>Seeks the media to the provided parameter, time in seconds.</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>
<tr>
<td><code>getDuration()</code></td>
<td>&mdash;</td>
<td>Will return a float with the duration in seconds.</td>
</tr>
<tr>
<td><code>getVolume()</code></td>
<td>&mdash;</td>
<td>Will return a float between 0 and 1 for the current volume level.</td>
</tr>
<tr>
<td><code>isMuted()</code></td>
<td>&mdash;</td>
<td>Will return a boolean for whether the media is currently muted.</td>
</tr>
<tr> <tr>
<td><code>setVolume(...)</code></td> <td><code>setVolume(...)</code></td>
<td>Number</td> <td>Number</td>
@ -590,11 +610,6 @@ Here's a list of the methods supported:
<td>&mdash;</td> <td>&mdash;</td>
<td>Restores the original element, reversing the effects of <code>setup()</code>.</td> <td>Restores the original element, reversing the effects of <code>setup()</code>.</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 v2.0.6 // plyr.js v2.0.7
// https://github.com/selz/plyr // https://github.com/selz/plyr
// License: The MIT License (MIT) // License: The MIT License (MIT)
// ========================================================================== // ==========================================================================
@ -43,7 +43,7 @@
displayDuration: true, displayDuration: true,
loadSprite: true, loadSprite: true,
iconPrefix: 'plyr', iconPrefix: 'plyr',
iconUrl: 'https://cdn.plyr.io/2.0.6/plyr.svg', iconUrl: 'https://cdn.plyr.io/2.0.7/plyr.svg',
clickToPlay: true, clickToPlay: true,
hideControls: true, hideControls: true,
showPosterOnEnd: false, showPosterOnEnd: false,
@ -2205,7 +2205,9 @@
} }
// Toggle muted state // Toggle muted state
if (plyr.media.muted && volume > 0) { if (volume === 0) {
plyr.media.muted = true;
} else if (plyr.media.muted && volume > 0) {
_toggleMute(); _toggleMute();
} }
} }
@ -3381,6 +3383,10 @@
getEmbed: function() { return plyr.embed; }, getEmbed: function() { return plyr.embed; },
getMedia: function() { return plyr.media; }, getMedia: function() { return plyr.media; },
getType: function() { return plyr.type; }, getType: function() { return plyr.type; },
getDuration: _getDuration,
getCurrentTime: function() { return plyr.media.currentTime; },
getVolume: function() { return plyr.media.volume; },
isMuted: function() { return plyr.media.muted; },
isReady: function() { return _hasClass(plyr.container, config.classes.ready); }, isReady: function() { return _hasClass(plyr.container, config.classes.ready); },
isLoading: function() { return _hasClass(plyr.container, config.classes.loading); }, isLoading: function() { return _hasClass(plyr.container, config.classes.loading); },
on: function(event, callback) { _on(plyr.container, event, callback); }, on: function(event, callback) { _on(plyr.container, event, callback); },
@ -3401,8 +3407,7 @@
toggleControls: _toggleControls, toggleControls: _toggleControls,
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
getCurrentTime: function() { return media.currentTime; }
}; };
// Everything done // Everything done