Updated manual caption split pattern
Previously, Plyr was using a fixed pattern of '\n\n' to split contents into captions. This does not always work as some VTT files contain '\r\n'. This commit checks for both.
This commit is contained in:
parent
67f19166ac
commit
402c45ee2b
@ -1523,12 +1523,18 @@
|
|||||||
record,
|
record,
|
||||||
req = xhr.responseText;
|
req = xhr.responseText;
|
||||||
|
|
||||||
records = req.split('\n\n');
|
var pattern = '\n';
|
||||||
|
records = req.split(pattern + pattern);
|
||||||
|
if(records.length === 1) {
|
||||||
|
// The '\n' pattern didn't work
|
||||||
|
// Try '\r\n'
|
||||||
|
pattern = '\r\n';
|
||||||
|
records = req.split(pattern + pattern);
|
||||||
|
}
|
||||||
for (var r = 0; r < records.length; r++) {
|
for (var r = 0; r < records.length; r++) {
|
||||||
record = records[r];
|
record = records[r];
|
||||||
plyr.captions[r] = [];
|
plyr.captions[r] = [];
|
||||||
plyr.captions[r] = record.split('\n');
|
plyr.captions[r] = record.split(pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove first element ('VTT')
|
// Remove first element ('VTT')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user