Fix js loading/playback issues

This commit is contained in:
Ruben van de Ven 2022-01-11 12:00:28 +01:00
parent 5f626b5b3c
commit d04ccd3c5b

View file

@ -311,7 +311,9 @@ class Annotator extends EventTarget {
fetch(metadata_req) fetch(metadata_req)
.then(response => response.ok ? response.json() : null) .then(response => response.ok ? response.json() : null)
.then(metadata => { .then(metadata => {
if (metadata !== null) {
metadata.annotations = metadata.annotations.map((a) => new Annotation(a.tag, a.t_in, a.t_out)) metadata.annotations = metadata.annotations.map((a) => new Annotation(a.tag, a.t_in, a.t_out))
}
this.loadStrokes(data, metadata) this.loadStrokes(data, metadata)
}) })
.catch(e => console.log(e)); .catch(e => console.log(e));
@ -754,7 +756,9 @@ class Annotator extends EventTarget {
} }
// when an outpoint is set, stop playing there // 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]; return [null, null];
} }
@ -945,7 +949,8 @@ class Annotator extends EventTarget {
getEndTimeMs() { getEndTimeMs() {
const videoDuration = this.getFinalFrameTime(); 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); return Math.max(videoDuration, audioDuration * 1000);
} }