From d02e57bdb387a1f03024533cf015951dfc50ff68 Mon Sep 17 00:00:00 2001 From: Amo Wu Date: Thu, 15 Dec 2016 16:38:46 +0800 Subject: [PATCH] fix: Firefox can not display captions --- src/js/plyr.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/js/plyr.js b/src/js/plyr.js index ddc20630..83c54976 100644 --- a/src/js/plyr.js +++ b/src/js/plyr.js @@ -1252,25 +1252,22 @@ captions = req.split(lineSeparator + lineSeparator); + var numOfAvailableCaptions = 0; + for (var r = 0; r < captions.length; r++) { caption = captions[r]; - plyr.captions[r] = []; // Get the parts of the captions var parts = caption.split(lineSeparator), index = 0; // Incase caption numbers are added - if (parts[index].indexOf(":") === -1) { - index = 1; + if (parts[index].indexOf(":") !== -1) { + plyr.captions[numOfAvailableCaptions] = [parts[index], parts[index + 1]]; + numOfAvailableCaptions ++; } - - plyr.captions[r] = [parts[index], parts[index + 1]]; } - // Remove first element ('VTT') - plyr.captions.shift(); - _log('Successfully loaded the caption file via AJAX'); } else { _warn(config.logPrefix + 'There was a problem loading the caption file via AJAX');