Skip to content

Commit

Permalink
Fixed API method, added new methods (fixes #346, #351)
Browse files Browse the repository at this point in the history
- Fixed `getCurrentTime()` method (fixes #351)
- Added `getVolume()` , `isMuted()` and `getDuration()` API methods (fixes #346)
  • Loading branch information
Sam committed Aug 29, 2016
1 parent 15fd704 commit 435b5c7
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 16 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v2.0.7
- Fixed `getCurrentTime()` method (fixes #351)
- Added `getVolume()` , `isMuted()` and `getDuration()` API methods (fixes #346)

## v2.0.6
- Fixed merge issue with `Updated define to work with AMD imports #326` PR
- Code formatting
Expand Down
4 changes: 2 additions & 2 deletions dist/plyr.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "plyr",
"version": "2.0.6",
"version": "2.0.7",
"description": "A simple, accessible and customizable HTML5, YouTube and Vimeo media player",
"homepage": "http://plyr.io",
"main": "src/js/plyr.js",
Expand Down
31 changes: 23 additions & 8 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

```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
Expand All @@ -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:

```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
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

Expand Down Expand Up @@ -529,6 +529,26 @@ Here's a list of the methods supported:
<td>Number</td>
<td>Seeks the media to the provided parameter, time in seconds.</td>
</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>
<td><code>setVolume(...)</code></td>
<td>Number</td>
Expand Down Expand Up @@ -590,11 +610,6 @@ Here's a list of the methods supported:
<td>&mdash;</td>
<td>Restores the original element, reversing the effects of <code>setup()</code>.</td>
</tr>
<tr>
<td><code>getCurrentTime()</code></td>
<td>&mdash;</td>
<td>Will return a float with the current time in seconds.</td>
</tr>
</tbody>
</table>

Expand Down
15 changes: 10 additions & 5 deletions src/js/plyr.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ==========================================================================
// Plyr
// plyr.js v2.0.6
// plyr.js v2.0.7
// https://github.com/selz/plyr
// License: The MIT License (MIT)
// ==========================================================================
Expand Down Expand Up @@ -43,7 +43,7 @@
displayDuration: true,
loadSprite: true,
iconPrefix: 'plyr',
iconUrl: 'https://cdn.plyr.io/2.0.6/plyr.svg',
iconUrl: 'https://cdn.plyr.io/2.0.7/plyr.svg',
clickToPlay: true,
hideControls: true,
showPosterOnEnd: false,
Expand Down Expand Up @@ -2205,7 +2205,9 @@
}

// Toggle muted state
if (plyr.media.muted && volume > 0) {
if (volume === 0) {
plyr.media.muted = true;
} else if (plyr.media.muted && volume > 0) {
_toggleMute();
}
}
Expand Down Expand Up @@ -3381,6 +3383,10 @@
getEmbed: function() { return plyr.embed; },
getMedia: function() { return plyr.media; },
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); },
isLoading: function() { return _hasClass(plyr.container, config.classes.loading); },
on: function(event, callback) { _on(plyr.container, event, callback); },
Expand All @@ -3401,8 +3407,7 @@
toggleControls: _toggleControls,
isFullscreen: function() { return plyr.isFullscreen || false; },
support: function(mimeType) { return _supportMime(plyr, mimeType); },
destroy: _destroy,
getCurrentTime: function() { return media.currentTime; }
destroy: _destroy
};

// Everything done
Expand Down

0 comments on commit 435b5c7

Please sign in to comment.