From d04ccd3c5b3c82b0d57240c0ea5c9984fc7dd404 Mon Sep 17 00:00:00 2001 From: Ruben van de Ven Date: Tue, 11 Jan 2022 12:00:28 +0100 Subject: [PATCH] Fix js loading/playback issues --- www/annotate.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/www/annotate.js b/www/annotate.js index 42fc7f7..ca87bc5 100644 --- a/www/annotate.js +++ b/www/annotate.js @@ -311,7 +311,9 @@ class Annotator extends EventTarget { fetch(metadata_req) .then(response => response.ok ? response.json() : null) .then(metadata => { - metadata.annotations = metadata.annotations.map((a) => new Annotation(a.tag, a.t_in, a.t_out)) + if (metadata !== null) { + metadata.annotations = metadata.annotations.map((a) => new Annotation(a.tag, a.t_in, a.t_out)) + } this.loadStrokes(data, metadata) }) .catch(e => console.log(e)); @@ -754,7 +756,9 @@ class Annotator extends EventTarget { } // when an outpoint is set, stop playing there - if (this.outPointPosition && (next_path > this.outPointPosition[0] || next_point > this.outPointPosition[1])) { + if (this.outPointPosition && (next_path > this.outPointPosition[0] || + (next_path == this.outPointPosition[0] && next_point > this.outPointPosition[1]))) { + console.log('> out point', this.outPointPosition) return [null, null]; } @@ -945,7 +949,8 @@ class Annotator extends EventTarget { getEndTimeMs() { const videoDuration = this.getFinalFrameTime(); - const audioDuration = (this.audioEl) ? this.audioEl.duration + this.audioOffset : 0; + const audioDuration = (this.audioEl && this.audioEl.src) ? this.audioEl.duration + this.audioOffset : 0; + return Math.max(videoDuration, audioDuration * 1000); }