diff options
author | Guru Prasad Srinivasa <gurupras@buffalo.edu> | 2016-02-16 19:52:08 -0500 |
---|---|---|
committer | Guru Prasad Srinivasa <gurupras@buffalo.edu> | 2016-02-16 19:52:08 -0500 |
commit | 67f19166ac92d5adc03c9421300149260a6424ac (patch) | |
tree | 3315429eab663286b6fabbdd5a2d509c33704a7b /src | |
parent | 32b7b6b88692a5fc3dd4443ae6f442fc400fdf92 (diff) | |
download | plyr-67f19166ac92d5adc03c9421300149260a6424ac.tar.lz plyr-67f19166ac92d5adc03c9421300149260a6424ac.tar.xz plyr-67f19166ac92d5adc03c9421300149260a6424ac.zip |
Some WebVTT fixes to allow manual captions
WebVTT allows additional parameters along with the line that
contains the start and end times. These were not being filtered
out while attempting to manually display captions.
Diffstat (limited to 'src')
-rw-r--r-- | src/js/plyr.js | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/js/plyr.js b/src/js/plyr.js index fce746db..2f50bb69 100644 --- a/src/js/plyr.js +++ b/src/js/plyr.js @@ -820,15 +820,21 @@ } // Utilities for caption time codes - function _timecodeMin(tc) { + function _timecodeCommon(tc, pos) { var tcpair = []; tcpair = tc.split(' --> '); - return _subTcSecs(tcpair[0]); + for(var i = 0; i < tcpair.length; i++) { + // WebVTT allows for extra meta data after the timestamp line + // So get rid of this if it exists + tcpair[i] = tcpair[i].replace(/(\d+:\d+:\d+\.\d+).*/, "$1"); + } + return _subTcSecs(tcpair[pos]); + } + function _timecodeMin(tc) { + return _timecodeCommon(tc, 0); } function _timecodeMax(tc) { - var tcpair = []; - tcpair = tc.split(' --> '); - return _subTcSecs(tcpair[1]); + return _timecodeCommon(tc, 1); } function _subTcSecs(tc) { if (tc === null || tc === undefined) { |