зеркало из https://github.com/mozilla/popcorn-js.git
[#291] Error checking, null tests
This commit is contained in:
Родитель
5c48a52063
Коммит
e119b92a70
|
@ -6,3 +6,7 @@ our final approach into Coruscant.
|
|||
2
|
||||
00:00:9.712 --> 00:00:13.399
|
||||
Very good, Lieutenant.
|
||||
|
||||
Track-3
|
||||
00:00:15.542 --> 00:00:18.542 A:start D:vertical L:98%
|
||||
It's a trap!
|
||||
|
|
|
@ -1,14 +1,39 @@
|
|||
1
|
||||
00:00:02.400 --> 00:00:07.200
|
||||
00:00:02.400 --> 00:00:07.200
|
||||
Senator, we're making
|
||||
our final approach into Coruscant.
|
||||
|
||||
2
|
||||
00:9.712 --> 00:13.399
|
||||
00:09.712-->00:13.399
|
||||
Very good, Lieutenant.
|
||||
|
||||
|
||||
|
||||
3
|
||||
00:00:13.400 --> 00:00:20
|
||||
A bad cue, no milliseconds. Should be ignored
|
||||
|
||||
-->
|
||||
00:00:14.456--> 00:00:20.000
|
||||
A bad cue, bad id. Should be ignored
|
||||
|
||||
4
|
||||
00:00:9.456--> 00:00:20.000
|
||||
A bad cue, seconds are single digit. Should be ignored
|
||||
|
||||
5
|
||||
00:1:00.456--> 00:00:20.000
|
||||
A bad cue, minutes are single digit. Should be ignored
|
||||
|
||||
6
|
||||
1:00:00.456--> 00:00:20.000
|
||||
A bad cue, hours are supplied as single digit. Should be ignored
|
||||
|
||||
7
|
||||
00:00:00.46--> 00:00:20.000
|
||||
A bad cue, ms are not 3 digits. Should be ignored
|
||||
|
||||
Track-3
|
||||
00:00:15.042 --> 00:00:18.042 A:start D:vertical L:98%
|
||||
It's a trap!
|
||||
|
||||
|
|
|
@ -2,23 +2,27 @@
|
|||
|
||||
(function (Popcorn) {
|
||||
Popcorn.parser( "parseVTT", "VTT", function( data ) {
|
||||
|
||||
|
||||
// declare needed variables
|
||||
var retObj = {
|
||||
title: "",
|
||||
remote: "",
|
||||
data: []
|
||||
},
|
||||
subs = [],
|
||||
lines,
|
||||
lines, time, text, sub,
|
||||
subs = [],
|
||||
i = 0, len = 0, idx = 0;
|
||||
|
||||
// [HH]:MM:SS.mmm string to SS.mmm
|
||||
// [HH:]MM:SS.mmm string to SS.mmm float
|
||||
// Throws exception if invalid
|
||||
var toSeconds = function(t_in) {
|
||||
var t = t_in.split(':');
|
||||
var time, l = t.length-1;
|
||||
var time, l = t_in.length;
|
||||
|
||||
try {
|
||||
if (l !== 12 && l !== 9) throw "Bad cue";
|
||||
l = t.length - 1;
|
||||
|
||||
try {
|
||||
time = parseInt(t[l-1], 10)*60 + parseFloat(t[l], 10);
|
||||
|
||||
if (l === 2) // Hours given
|
||||
|
@ -40,14 +44,16 @@
|
|||
len = lines.length;
|
||||
|
||||
while (i < len) {
|
||||
var sub = {};
|
||||
|
||||
sub.id = lines[i++];
|
||||
|
||||
var time = lines[i++].split(" --> ");
|
||||
var text = [];
|
||||
sub = {};
|
||||
text = [];
|
||||
|
||||
try {
|
||||
sub.id = lines[i++];
|
||||
|
||||
if (!sub.id || sub.id.indexOf("-->") !== -1) throw "Bad cue";
|
||||
|
||||
time = lines[i++].split(/[\t ]*-->[\t ]*/);
|
||||
|
||||
sub.start = toSeconds(time[0]);
|
||||
|
||||
// Filter out any trailing styling info
|
||||
|
|
|
@ -26,6 +26,7 @@ popcorn-api-draft.js
|
|||
<video id='video'
|
||||
controls
|
||||
width= '250px'
|
||||
data-timeline-sources="data/unit.vtt"
|
||||
poster="../../test/poster.png">
|
||||
|
||||
<source id='mp4'
|
||||
|
|
|
@ -30,11 +30,11 @@ test("Popcorn 0.3 VTT Parser Plugin", function () {
|
|||
}
|
||||
}
|
||||
|
||||
poppercorn.parseVTT("data/unit.vtt");
|
||||
poppercorn.parseVTT(document.getElementById('video').getAttribute('data-timeline-sources'));
|
||||
|
||||
expect(expects);
|
||||
|
||||
stop( 10000 );
|
||||
stop( 5000 );
|
||||
|
||||
// Allow load time
|
||||
setTimeout(function () {
|
||||
|
|
Загрузка…
Ссылка в новой задаче