aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--assets/js/plyr.js23
1 files changed, 8 insertions, 15 deletions
diff --git a/assets/js/plyr.js b/assets/js/plyr.js
index 2b13cdbc..923b3dce 100644
--- a/assets/js/plyr.js
+++ b/assets/js/plyr.js
@@ -571,30 +571,23 @@
if (captionSrc !== "") {
// Create XMLHttpRequest Object
- var xhr;
- if (window.XMLHttpRequest) {
- xhr = new XMLHttpRequest();
- }
- else if (window.ActiveXObject) { // IE8
- xhr = new ActiveXObject("Microsoft.XMLHTTP");
- }
+ var xhr = new XMLHttpRequest();
+
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
- if (config.debug) {
- console.log("xhr = 200");
- }
-
player.captions = [];
var records = [],
record,
req = xhr.responseText;
+
records = req.split("\n\n");
for (var r=0; r < records.length; r++) {
record = records[r];
player.captions[r] = [];
player.captions[r] = record.split("\n");
}
+
// Remove first element ("VTT")
player.captions.shift();
@@ -602,14 +595,14 @@
console.log("Successfully loaded the caption file via ajax.");
}
}
- else {
- if (config.debug) {
- console.log("There was a problem loading the caption file via ajax.");
- }
+ else if (config.debug) {
+ console.error("There was a problem loading the caption file via ajax.");
}
}
}
+
xhr.open("get", captionSrc, true);
+
xhr.send();
}
}