From 6be3f0d12cf2591ec961f991eeff6c612753569a Mon Sep 17 00:00:00 2001 From: Brook Gagnon Date: Sun, 11 Aug 2024 17:03:36 +0000 Subject: [PATCH] use extracted video/audio thumbnail in preview player --- ui/elements/preview.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/ui/elements/preview.js b/ui/elements/preview.js index 28b7b4a7..f393ecc4 100644 --- a/ui/elements/preview.js +++ b/ui/elements/preview.js @@ -157,17 +157,15 @@ class OBElementPreview extends OBElement { const videoElem = this.root.querySelector("video-js"); if (videoElem) { let elem = this; + let thumbnailId = this.#queue[this.#itemId].id; + let thumbnailLink = "/thumbnail.php?id=" + thumbnailId; + let validThumbnail = (await fetch(thumbnailLink)).ok; + if (!validThumbnail) { + thumbnailLink = "/images/circle.svg"; + } switch (this.#itemType) { case "audio": - let thumbnailId = this.#queue[this.#itemId].id; - let thumbnailLink = - "/preview.php?x=" + new Date().getTime() + "&id=" + thumbnailId + "&thumbnail=1"; - let validThumbnail = (await fetch(thumbnailLink)).ok; - if (!validThumbnail) { - thumbnailLink = "/images/circle.svg"; - } - this.#videojsPlayer = videojs(videoElem, { controls: true, preload: "auto", @@ -186,6 +184,7 @@ class OBElementPreview extends OBElement { this.#videojsPlayer = videojs(videoElem, { controls: true, preload: "auto", + poster: thumbnailLink, }); this.#videojsPlayer.ready(function () {