* Creates an instance of Caption. * @param {TimedLine[]} lines - Array of lines to be used for caption. * @memberof Caption
(lines)
| 17 | * @memberof Caption |
| 18 | */ |
| 19 | constructor(lines) { |
| 20 | this.lines = lines; |
| 21 | |
| 22 | // Sort by end time, this ensures proper execution order of lines. |
| 23 | this.lines.sort(function (a, b) { |
| 24 | if (a.endTime < b.endTime) { |
| 25 | return -1; |
| 26 | } |
| 27 | |
| 28 | if (a.endTime > b.endTime) { |
| 29 | return 1; |
| 30 | } |
| 31 | |
| 32 | return 0; |
| 33 | }); |
| 34 | |
| 35 | this.reset(); |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Resets time, lineIndex and content fields. |