diff options
author | Sam Potts <sam@selz.com> | 2016-10-01 22:10:35 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-01 22:10:35 +1000 |
commit | 8098be6f935b153c28e2979bdfbabc1397bfd769 (patch) | |
tree | 24bf9a65b0970eb8370dd26e74c8d978cd7adf3c /src/js/plyr.js | |
parent | 978606edb4a9c628c337a9c1ccb00fc35db12212 (diff) | |
parent | 1c73c9fbfe0aa8194d8591a24e97d96866cf77c2 (diff) | |
download | plyr-8098be6f935b153c28e2979bdfbabc1397bfd769.tar.lz plyr-8098be6f935b153c28e2979bdfbabc1397bfd769.tar.xz plyr-8098be6f935b153c28e2979bdfbabc1397bfd769.zip |
Merge pull request #379 from magourex/master
Support WebVTT with CRLF or LF Line separator with firefox #378
Diffstat (limited to 'src/js/plyr.js')
-rw-r--r-- | src/js/plyr.js | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/js/plyr.js b/src/js/plyr.js index 9af0ad05..18099312 100644 --- a/src/js/plyr.js +++ b/src/js/plyr.js @@ -1025,15 +1025,26 @@ var captions = [], caption, req = xhr.responseText; - - captions = req.split('\n\n'); + + //According to webvtt spec, line terminator consists of one of the following + // CRLF (U+000D U+000A), LF (U+000A) or CR (U+000D) + var lineSeparator = '\r\n'; + if(req.indexOf(lineSeparator+lineSeparator) === -1) { + if(req.indexOf('\r\r') !== -1){ + lineSeparator = '\r'; + } else { + lineSeparator = '\n'; + } + } + + captions = req.split(lineSeparator+lineSeparator); for (var r = 0; r < captions.length; r++) { caption = captions[r]; plyr.captions[r] = []; // Get the parts of the captions - var parts = caption.split('\n'), + var parts = caption.split(lineSeparator), index = 0; // Incase caption numbers are added |