From 24cb668071af7282da95d22493afd2619de548bb Mon Sep 17 00:00:00 2001 From: Edward Silverton Date: Wed, 25 Sep 2024 15:36:30 +0100 Subject: [PATCH] added autoPlayOnSetTarget config option --- .../uv-mediaelement-extension/config/Config.ts | 1 + .../uv-mediaelement-extension/config/config.json | 1 + .../MediaElementCenterPanel.ts | 13 ++++++++----- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/content-handlers/iiif/extensions/uv-mediaelement-extension/config/Config.ts b/src/content-handlers/iiif/extensions/uv-mediaelement-extension/config/Config.ts index 400c80bc4..9333a6412 100644 --- a/src/content-handlers/iiif/extensions/uv-mediaelement-extension/config/Config.ts +++ b/src/content-handlers/iiif/extensions/uv-mediaelement-extension/config/Config.ts @@ -12,6 +12,7 @@ import { } from "@/content-handlers/iiif/BaseConfig"; type MediaElementCenterPanelOptions = CenterPanelOptions & { + autoPlayOnSetTarget: boolean; defaultHeight: number; defaultWidth: number; }; diff --git a/src/content-handlers/iiif/extensions/uv-mediaelement-extension/config/config.json b/src/content-handlers/iiif/extensions/uv-mediaelement-extension/config/config.json index 7ca31ede6..647929709 100644 --- a/src/content-handlers/iiif/extensions/uv-mediaelement-extension/config/config.json +++ b/src/content-handlers/iiif/extensions/uv-mediaelement-extension/config/config.json @@ -158,6 +158,7 @@ }, "mediaelementCenterPanel": { "options": { + "autoPlayOnSetTarget": true, "defaultHeight": 420, "defaultWidth": 560, "titleEnabled": true, diff --git a/src/content-handlers/iiif/modules/uv-mediaelementcenterpanel-module/MediaElementCenterPanel.ts b/src/content-handlers/iiif/modules/uv-mediaelementcenterpanel-module/MediaElementCenterPanel.ts index 33ed624fb..d9821a5eb 100644 --- a/src/content-handlers/iiif/modules/uv-mediaelementcenterpanel-module/MediaElementCenterPanel.ts +++ b/src/content-handlers/iiif/modules/uv-mediaelementcenterpanel-module/MediaElementCenterPanel.ts @@ -72,13 +72,16 @@ export class MediaElementCenterPanel extends CenterPanel< } this.player.setCurrentTime(startTime); - this.player.play(); - const duration = (endTime - startTime) * 1000; + if (this.config.options.autoPlayOnSetTarget) { + this.player.play(); - setTimeout(() => { - this.player.pause(); - }, duration); + const duration = (endTime - startTime) * 1000; + + setTimeout(() => { + this.player.pause(); + }, duration); + } return; }