Skip to content

Commit

Permalink
use extracted video/audio thumbnail in preview player
Browse files Browse the repository at this point in the history
  • Loading branch information
brookgagnon committed Aug 11, 2024
1 parent dca4379 commit 6be3f0d
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions ui/elements/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -186,6 +184,7 @@ class OBElementPreview extends OBElement {
this.#videojsPlayer = videojs(videoElem, {
controls: true,
preload: "auto",
poster: thumbnailLink,
});

this.#videojsPlayer.ready(function () {
Expand Down

0 comments on commit 6be3f0d

Please sign in to comment.