Optional url prefix to put audio and poster into subdir
This commit is contained in:
parent
23283212d6
commit
4bab75ca5b
1 changed files with 7 additions and 4 deletions
|
@ -147,6 +147,7 @@ class Annotator extends EventTarget {
|
||||||
crop_to_fit: config && config.hasOwnProperty('crop_to_fit') ? config.crop_to_fit : false, // DEPRECATED don't animate viewport, but show the whole drawing
|
crop_to_fit: config && config.hasOwnProperty('crop_to_fit') ? config.crop_to_fit : false, // DEPRECATED don't animate viewport, but show the whole drawing
|
||||||
crop: config && config.hasOwnProperty('crop') && Object.values(CropOptions).indexOf(config.crop) !== -1 ? config.crop : CropOptions.Fit_Selection, // don't animate viewport, but show the whole drawing
|
crop: config && config.hasOwnProperty('crop') && Object.values(CropOptions).indexOf(config.crop) !== -1 ? config.crop : CropOptions.Fit_Selection, // don't animate viewport, but show the whole drawing
|
||||||
autoplay: config && config.hasOwnProperty('autoplay') ? config.autoplay : false, // immediately start playback
|
autoplay: config && config.hasOwnProperty('autoplay') ? config.autoplay : false, // immediately start playback
|
||||||
|
url_prefix: config && config.hasOwnProperty('url_prefix') ? config.url_prefix : '',
|
||||||
}
|
}
|
||||||
|
|
||||||
this.formatter = wNumb({
|
this.formatter = wNumb({
|
||||||
|
@ -772,10 +773,10 @@ class Annotator extends EventTarget {
|
||||||
|
|
||||||
if ((metadata && metadata.hasOwnProperty('audio')) || (drawing.hasOwnProperty('audio') && drawing.audio)) {
|
if ((metadata && metadata.hasOwnProperty('audio')) || (drawing.hasOwnProperty('audio') && drawing.audio)) {
|
||||||
if (metadata && metadata.hasOwnProperty('audio')) {
|
if (metadata && metadata.hasOwnProperty('audio')) {
|
||||||
this.audioFile = metadata.audio.file
|
this.audioFile = this.config.url_prefix + metadata.audio.file
|
||||||
this.audioOffset = Number.parseFloat(metadata.audio.offset);
|
this.audioOffset = Number.parseFloat(metadata.audio.offset);
|
||||||
} else {
|
} else {
|
||||||
this.audioFile = drawing.audio.file
|
this.audioFile = this.config.url_prefix + drawing.audio.file
|
||||||
this.audioOffset = Number.parseFloat(drawing.audio.offset);
|
this.audioOffset = Number.parseFloat(drawing.audio.offset);
|
||||||
}
|
}
|
||||||
this._currentTimeMs = this.audioOffset < 0 ? this.audioOffset * 1000 : 0;
|
this._currentTimeMs = this.audioOffset < 0 ? this.audioOffset * 1000 : 0;
|
||||||
|
@ -1584,21 +1585,23 @@ class AnnotationPlayer extends HTMLElement {
|
||||||
imgWrapEl.appendChild(imgEl);
|
imgWrapEl.appendChild(imgEl);
|
||||||
|
|
||||||
const playerEl = document.createElement('div');
|
const playerEl = document.createElement('div');
|
||||||
|
const url_prefix = this.hasAttribute('data-url-prefix') ? this.getAttribute('data-url-prefix') + '/' : '';
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
is_player: true,
|
is_player: true,
|
||||||
crop: this.hasAttribute('data-crop') ? this.getAttribute('data-crop') : null,
|
crop: this.hasAttribute('data-crop') ? this.getAttribute('data-crop') : null,
|
||||||
autoplay: true,
|
autoplay: true,
|
||||||
|
url_prefix: url_prefix,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
imgEl.src = this.getAttribute('data-poster-url');
|
imgEl.src = url_prefix + this.getAttribute('data-poster-url');
|
||||||
imgEl.addEventListener('click', () => {
|
imgEl.addEventListener('click', () => {
|
||||||
imgEl.style.display = 'none';
|
imgEl.style.display = 'none';
|
||||||
this.annotator = new Annotator(
|
this.annotator = new Annotator(
|
||||||
playerEl,
|
playerEl,
|
||||||
null, //"tags.json",
|
null, //"tags.json",
|
||||||
this.getAttribute('data-annotation-url'),
|
url_prefix + this.getAttribute('data-annotation-url'),
|
||||||
config
|
config
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue