diff --git a/src/components/canvas-instance.ts b/src/components/canvas-instance.ts index 96dfa06..2a45095 100644 --- a/src/components/canvas-instance.ts +++ b/src/components/canvas-instance.ts @@ -5,7 +5,7 @@ import { convertToPercentage } from '../helpers/convert-to-percentage'; const $ = require('jquery'); import { Annotation, AnnotationBody, Canvas, Duration, Range, Utils } from 'manifesto.js'; -import { Behavior, MediaType } from '@iiif/vocabulary/dist-commonjs'; +import { Behavior, MediaType, RenderingFormat } from '@iiif/vocabulary/dist-commonjs'; import { BaseComponent, IBaseComponentOptions } from '@iiif/base-component'; import { IAVCanvasInstanceData } from '../interfaces/canvas-instance-data'; import { MediaElement } from '../elements/media-element'; @@ -35,6 +35,13 @@ import { getHls } from '../helpers/get-hls'; import 'waveform-panel'; import { WaveformPanel } from 'waveform-panel'; +type AugmentedRenderingFormat = RenderingFormat | "text/vtt"; +type TextTrackDescriptor = { + language?: string; + label?: string; + id: string; +}; + export class CanvasInstance extends BaseComponent { private _$canvasContainer: JQuery; private _$canvasDuration: JQuery; @@ -43,6 +50,8 @@ export class CanvasInstance extends BaseComponent { private _$canvasTime: JQuery; private _$canvasTimelineContainer: JQuery; private _$controlsContainer: JQuery; + private _$captionsButton: JQuery; + private _$captionsContainer: JQuery; private _$durationHighlight: JQuery; private _$hoverPreviewTemplate: JQuery; private _$nextButton: JQuery; @@ -62,6 +71,7 @@ export class CanvasInstance extends BaseComponent { private _canvasClockTime: TimelineTime = 0 as TimelineTime; private _canvasHeight = 0; private _canvasWidth = 0; + private _captionsSelectedIndex = 0; // hide captions by default private _waveformPanel?: WaveformPanel; private _contentAnnotations: any[]; // todo: type as HTMLMediaElement? private _data: IAVCanvasInstanceData = this.data(); @@ -95,7 +105,6 @@ export class CanvasInstance extends BaseComponent { this._$element = $(this.options.target); this._data = this.options.data; this.$playerElement = $('
'); - this.$playerElement.hide(); } public loaded(): void { @@ -267,12 +276,19 @@ export class CanvasInstance extends BaseComponent { ${this._data.content.fastRewind || ''} `); + this._$captionsButton = $(` +