- play |
+ play() |
— |
Plays the media |
- pause |
+ pause() |
— |
Pauses the media |
- restart |
+ restart() |
— |
Restarts playback |
- rewind |
+ rewind(...) |
Number |
Rewinds by the provided parameter, in seconds. If no parameter is provided, the default seekInterval is used (10 seconds). |
- forward |
+ forward(...) |
Number |
Fast forwards by the provided parameter, in seconds. If no parameter is provided, the default seekInterval is used (10 seconds). |
- seek |
+ seek(...) |
Number |
Seeks the media to the provided parameter, time in seconds. |
- setVolume |
+ setVolume(...) |
Number |
Sets the player volume to the provided parameter. The value should be between 0 (muted) and 10 (loudest). If no parameter is provided, the default volume is used (5). Values over 10 are ignored. |
- toggleMute |
+ toggleMute() |
— |
Toggles mute for the player. |
- toggleCaptions |
+ toggleCaptions() |
— |
Toggles whether captions are enabled. |
+
+ support(...) |
+ String |
+ Determine if a player supports a certain MIME type. |
+
+
+ source(...) |
+ String, Object or Array |
+
+ Set the media source.
+
+ string
+ .source("/path/to/video.mp4")
+ This will set the "src" attribute on the `video` or `audio` element.
+
+ array
+ .source([{ src: "/path/to/video.webm", type: "video/webm", ...more attributes... }, { src: "/path/to/video.mp4", type: "video/mp4", ...more attributes... }])
+ This will inject a child `source` element for every element in the array with the specified attributes. `src` is the only required attribute although adding `type` is recommended as it helps the browser decide which file to download and play.
+ |
+
+
+ poster(...) |
+ String |
+ Set the poster url. This is supported for the `video` element only. |
+
diff --git a/src/js/plyr.js b/src/js/plyr.js
index 68fd0653..f8222173 100644
--- a/src/js/plyr.js
+++ b/src/js/plyr.js
@@ -1,6 +1,6 @@
// ==========================================================================
// Plyr
-// plyr.js v1.0.21
+// plyr.js v1.0.22
// https://github.com/sampotts/plyr
// License: The MIT License (MIT)
// ==========================================================================
@@ -142,7 +142,7 @@
}
// Credits: http://paypal.github.io/accessible-html5-video-player/
- // Unfortunately, due to scattered support, browser sniffing is required
+ // Unfortunately, due to mixed support, UA sniffing is required
function _browserSniff() {
var nAgt = navigator.userAgent,
browserName = navigator.appName,
@@ -469,16 +469,14 @@
if (player.media.currentTime.toFixed(1) >= _timecodeMin(player.captions[player.subcount][0]) &&
player.media.currentTime.toFixed(1) <= _timecodeMax(player.captions[player.subcount][0])) {
player.currentCaption = player.captions[player.subcount][1];
- }
- // Is there a next timecode?
- if (player.media.currentTime.toFixed(1) > _timecodeMax(player.captions[player.subcount][0]) &&
- player.subcount < (player.captions.length-1)) {
- player.subcount++;
+ // Render the caption
+ player.captionsContainer.innerHTML = player.currentCaption;
+ }
+ else {
+ // Clear the caption
+ player.captionsContainer.innerHTML = "";
}
-
- // Render the caption
- player.captionsContainer.innerHTML = player.currentCaption;
}
// Display captions container and button (for initialization)
@@ -747,7 +745,6 @@
// Render captions from array at appropriate time
player.currentCaption = "";
- player.subcount = 0;
player.captions = [];
if (captionSrc !== "") {
@@ -849,8 +846,8 @@
}
// Seek to time
- // The parameter can be an event or a number
- var _seek = function(input) {
+ // The input parameter can be an event or a number
+ function _seek(input) {
var targetTime = 0;
// Explicit position
@@ -858,10 +855,10 @@
targetTime = input;
}
// Event
- else if (input.type === "change" || input.type === "input") {
+ else if (typeof input === "object" && (input.type === "change" || input.type === "input")) {
// It's the seek slider
// Seek to the selected time
- targetTime = ((this.value / this.max) * player.media.duration);
+ targetTime = ((input.target.value / input.target.max) * player.media.duration);
}
// Normalise targetTime
@@ -879,7 +876,7 @@
_log("Seeking to " + player.media.currentTime + " seconds");
// Special handling for "manual" captions
- _seekManualCaptions(0);
+ _seekManualCaptions(targetTime);
}
// Check playing state
@@ -1085,57 +1082,20 @@
// Inject a source
function _addSource(attributes) {
- // Create a new