(realtime)
| 1312 | } |
| 1313 | |
| 1314 | loop(realtime) { |
| 1315 | for (let layer of this.layers) { |
| 1316 | if (layer.start_time + layer.total_time > this.total_time) { |
| 1317 | this.total_time = layer.start_time + layer.total_time; |
| 1318 | } |
| 1319 | } |
| 1320 | // draw time |
| 1321 | if (this.last_step === null) { |
| 1322 | this.last_step = realtime; |
| 1323 | } |
| 1324 | if (this.playing && this.total_time > 0) { |
| 1325 | this.time += (realtime - this.last_step); |
| 1326 | if (this.onend_callback && this.time >= this.total_time) { |
| 1327 | this.onend_callback(this); |
| 1328 | this.onend_callback = null; |
| 1329 | } |
| 1330 | if (this.time >= this.total_time) { |
| 1331 | this.refresh_audio(); |
| 1332 | } |
| 1333 | this.time %= this.total_time; |
| 1334 | } |
| 1335 | this.last_step = realtime; |
| 1336 | this.time_ctx.clearRect(0, 0, this.time_canvas.clientWidth, this.time_canvas.clientWidth); |
| 1337 | let x = this.time_canvas.clientWidth * this.time / this.total_time; |
| 1338 | this.time_ctx.fillStyle = `rgb(210,210,210)`; |
| 1339 | this.time_ctx.fillRect(x, 0, 2, this.time_canvas.clientHeight); |
| 1340 | this.time_ctx.font = "10px courier"; |
| 1341 | this.time_ctx.fillText(this.time.toFixed(2), x + 5, 10); |
| 1342 | this.time_ctx.fillText(this.total_time.toFixed(2), x + 5, 20); |
| 1343 | |
| 1344 | if (this.aux_time > 0) { |
| 1345 | let aux_x = this.time_canvas.clientWidth * this.aux_time / this.total_time; |
| 1346 | this.time_ctx.fillStyle = `rgb(110,110,110)`; |
| 1347 | this.time_ctx.fillRect(aux_x, 0, 1, this.time_canvas.clientHeight); |
| 1348 | this.render(this.cursor_ctx, this.aux_time, false); |
| 1349 | } |
| 1350 | |
| 1351 | let y_inc = this.time_canvas.clientHeight / (this.layers.length + 1); |
| 1352 | let y_coord = this.time_canvas.clientHeight - y_inc; |
| 1353 | for (let layer of this.layers) { |
| 1354 | let selected = this.selected_layer == layer; |
| 1355 | layer.render_time(this.time_ctx, y_coord, 3, selected); |
| 1356 | y_coord -= y_inc; |
| 1357 | if (this.selected_layer == layer && this.update) { |
| 1358 | layer.update(this.update, this.time); |
| 1359 | this.update = null; |
| 1360 | } |
| 1361 | } |
| 1362 | this.render(this.ctx, this.time, true); |
| 1363 | window.requestAnimationFrame(this.loop.bind(this)); |
| 1364 | } |
| 1365 | |
| 1366 | addFile(file) { |
| 1367 | if (file.type.indexOf('video') >= 0) { |
nothing calls this directly
no test coverage detected