1
0
mirror of https://github.com/videojs/video.js.git synced 2024-12-25 02:42:10 +02:00

Fixed issues around webvtt cue time parsing. Fixed #877, fixed #183.. closes #1236

This commit is contained in:
Troy Brandt 2014-06-13 13:30:16 -07:00 committed by Steve Heffernan
parent 91aa06fe56
commit bb50466733
3 changed files with 14 additions and 12 deletions

View File

@ -4,6 +4,7 @@ CHANGELOG
## HEAD (Unreleased)
* Added cross-browser isArray for cross-frame support. fixes #1195 ([view](https://github.com/videojs/video.js/pull/1218))
* Fixed support for webvtt chapters. Fixes #676. ([view](https://github.com/videojs/video.js/pull/1221))
* Fixed issues around webvtt cue time parsing. Fixed #877, fixed #183. ([view](https://github.com/videojs/video.js/pull/1236))
--------------------

View File

@ -482,9 +482,9 @@ vjs.TextTrack.prototype.parseCues = function(srcContent) {
};
// Timing line
time = line.split(' --> ');
time = line.split(/[\t ]+/);
cue.startTime = this.parseCueTime(time[0]);
cue.endTime = this.parseCueTime(time[1]);
cue.endTime = this.parseCueTime(time[2]);
// Additional lines - Cue Text
text = [];

View File

@ -21,10 +21,6 @@ test('cue time parsing', function() {
equal(parse('11:11'), 671, 'Only minutes and seconds (11:11)');
equal(parse('11:11:11'), 40271, 'Hours, minutes, seconds (11:11:11)');
equal(parse('11:11:11.111'), 40271.111, 'Hours, minutes, seconds, decimals (11:11:11.111)');
// Uncommment to test a fix for #877
// equal(parse('11:11 line:90%'), 671, 'minutes, seconds with flags');
// equal(parse('11:11:11 line:90%'), 40271, 'hours, minutes, seconds with flags');
});
test('cue parsing', function() {
@ -43,10 +39,15 @@ test('cue parsing', function() {
equal(mockTrack.cues_[0].endTime, 4.11, 'Cue end time w/ spaces');
equal(mockTrack.cues_[0].text, 'Text line 1', 'Cue text');
// Uncomment to test a fix for #183
// mockTrack.reset(); // reset mock track
// var timeWithTabs = vttHead + '00:00.700\t-->\t00:04.110\nText line 1';
// mockTrack.parseCues(timeWithTabs);
// equal(mockTrack.cues_[0].startTime, 0.7, 'Cue start time w/ spaces');
// equal(mockTrack.cues_[0].endTime, 4.11, 'Cue end time w/ spaces');
mockTrack.reset(); // reset mock track
var timeWithTabs = vttHead + '00:00.700\t-->\t00:04.110\nText line 1';
mockTrack.parseCues(timeWithTabs);
equal(mockTrack.cues_[0].startTime, 0.7, 'Cue start time w/ spaces');
equal(mockTrack.cues_[0].endTime, 4.11, 'Cue end time w/ spaces');
mockTrack.reset(); // reset mock track
var timeWithMixedWhiteSpace = vttHead + '00:00.700 -->\t 00:04.110\nText line 1';
mockTrack.parseCues(timeWithMixedWhiteSpace);
equal(mockTrack.cues_[0].startTime, 0.7, 'Cue start time w/ spaces');
equal(mockTrack.cues_[0].endTime, 4.11, 'Cue end time w/ spaces');
});