Skip to content

Commit 37b1436

Browse files
[BUGFIX] prevent loading media sources from shaka-player video elements (kitodo#1705)
Co-authored-by: Sebastian Meyer <sebastian.meyer@opencultureconsulting.com>
1 parent 98f630c commit 37b1436

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

Resources/Private/JavaScript/DlfMediaPlayer/DlfMediaPlayer.js

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -601,28 +601,30 @@ export default class DlfMediaPlayer extends HTMLElement {
601601
const sources = [];
602602

603603
this.querySelectorAll('source').forEach((el) => {
604-
const url = el.getAttribute("src");
605-
const mimeType = el.getAttribute("type");
604+
if (!el.closest('.shaka-video-container')) {
605+
const url = el.getAttribute("src");
606+
const mimeType = el.getAttribute("type");
606607

607-
if (!url || !mimeType) {
608-
console.warn('Ignoring <source> that does not specify URL or MIME type');
609-
return;
610-
}
608+
if (!url || !mimeType) {
609+
console.warn('Ignoring <source> that does not specify URL or MIME type');
610+
return;
611+
}
611612

612-
/** @type {dlf.media.Source['frameRate']} */
613-
let frameRate = null;
614-
const attrFps = el.getAttribute("data-fps");
615-
if (attrFps !== null) {
616-
const fps = parseFloat(attrFps);
617-
if (fps > 0) {
618-
// Also excludes empty "data-fps" or NaN
619-
frameRate = fps;
613+
/** @type {dlf.media.Source['frameRate']} */
614+
let frameRate = null;
615+
const attrFps = el.getAttribute("data-fps");
616+
if (attrFps !== null) {
617+
const fps = parseFloat(attrFps);
618+
if (fps > 0) {
619+
// Also excludes empty "data-fps" or NaN
620+
frameRate = fps;
621+
}
620622
}
621-
}
622623

623-
const fileId = el.getAttribute("data-fileid");
624+
const fileId = el.getAttribute("data-fileid");
624625

625-
sources.push({ url, mimeType, frameRate, fileId });
626+
sources.push({ url, mimeType, frameRate, fileId });
627+
}
626628
});
627629

628630
this.loadOneOf(sources);

Resources/Public/JavaScript/DlfMediaPlayer/DlfMediaPlayer.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)