aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--readme.md2
-rw-r--r--src/js/captions.js5
-rw-r--r--src/js/defaults.js3
3 files changed, 9 insertions, 1 deletions
diff --git a/readme.md b/readme.md
index 89a459b6..e925152f 100644
--- a/readme.md
+++ b/readme.md
@@ -303,7 +303,7 @@ Note the single quotes encapsulating the JSON and double quotes on the object ke
| `invertTime` | Boolean | `true` | Display the current time as a countdown rather than an incremental counter. |
| `toggleInvert` | Boolean | `true` | Allow users to click to toggle the above. |
| `listeners` | Object | `null` | Allows binding of event listeners to the controls before the default handlers. See the `defaults.js` for available listeners. If your handler prevents default on the event (`event.preventDefault()`), the default handler will not fire. |
-| `captions` | Object | `{ active: false, language: window.navigator.language.split('-')[0] }` | `active`: Toggles if captions should be active by default. `language`: Sets the default language to load (if available). |
+| `captions` | Object | `{ active: false, language: browser language, update: false }` | `active`: Toggles if captions should be active by default. `language`: Sets the default language to load (if available). `update`: Listen to changes to tracks and update menu. This is needed for some streaming libraries, but can result in unselectable language options). |
| `fullscreen` | Object | `{ enabled: true, fallback: true, iosNative: false }` | `enabled`: Toggles whether fullscreen should be enabled. `fallback`: Allow fallback to a full-window solution. `iosNative`: whether to use native iOS fullscreen when entering fullscreen (no custom controls) |
| `ratio` | String | `16:9` | The aspect ratio you want to use for embedded players. |
| `storage` | Object | `{ enabled: true, key: 'plyr' }` | `enabled`: Allow use of local storage to store user settings. `key`: The key name to use. |
diff --git a/src/js/captions.js b/src/js/captions.js
index 296888b2..5941ebda 100644
--- a/src/js/captions.js
+++ b/src/js/captions.js
@@ -83,6 +83,11 @@ const captions = {
// Set toggled state
this.toggleCaptions(active);
+ // Watch changes to textTracks and update captions menu
+ if (this.config.captions.update) {
+ utils.on(this.media.textTracks, 'change', captions.update.bind(this));
+ }
+
// Update available languages in list
captions.update.call(this);
},
diff --git a/src/js/defaults.js b/src/js/defaults.js
index 5b1a4dd3..dc8785d5 100644
--- a/src/js/defaults.js
+++ b/src/js/defaults.js
@@ -116,6 +116,9 @@ const defaults = {
captions: {
active: false,
language: (navigator.language || navigator.userLanguage).split('-')[0],
+ // Listen to new tracks added after Plyr is initialized.
+ // This is needed for streaming captions, but may result in unselectable options
+ update: false,
},
// Fullscreen settings