From 23a22d6b24c7e2808c2fb14a315061a9f5ce5c37 Mon Sep 17 00:00:00 2001 From: TheMelmacian <76712303+TheMelmacian@users.noreply.github.com> Date: Fri, 7 Jul 2023 22:54:44 +0200 Subject: [PATCH] use random backdrop image in video player --- src/components/playback/playbackmanager.js | 25 ++-------------------- src/plugins/htmlVideoPlayer/plugin.js | 8 ++++++- 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/src/components/playback/playbackmanager.js b/src/components/playback/playbackmanager.js index 308acd79f5..8e09a45de0 100644 --- a/src/components/playback/playbackmanager.js +++ b/src/components/playback/playbackmanager.js @@ -14,6 +14,7 @@ import alert from '../alert'; import { PluginType } from '../../types/plugin.ts'; import { includesAny } from '../../utils/container.ts'; import { getItems } from '../../utils/jellyfin-apiclient/getItems.ts'; +import { getRandomItemBackdropImageUrl } from '../../utils/url'; const UNLIMITED_ITEMS = -1; @@ -154,28 +155,6 @@ function mergePlaybackQueries(obj1, obj2) { return query; } -function backdropImageUrl(apiClient, item, options) { - options = options || {}; - options.type = options.type || 'Backdrop'; - - // If not resizing, get the original image - if (!options.maxWidth && !options.width && !options.maxHeight && !options.height && !options.fillWidth && !options.fillHeight) { - options.quality = 100; - } - - if (item.BackdropImageTags?.length) { - options.tag = item.BackdropImageTags[0]; - return apiClient.getScaledImageUrl(item.Id, options); - } - - if (item.ParentBackdropImageTags?.length) { - options.tag = item.ParentBackdropImageTags[0]; - return apiClient.getScaledImageUrl(item.ParentBackdropItemId, options); - } - - return null; -} - function getMimeType(type, container) { container = (container || '').toLowerCase(); @@ -2693,7 +2672,7 @@ class PlaybackManager { title: item.Name }; - const backdropUrl = backdropImageUrl(apiClient, item, {}); + const backdropUrl = getRandomItemBackdropImageUrl(apiClient, item); if (backdropUrl) { resultInfo.backdropUrl = backdropUrl; } diff --git a/src/plugins/htmlVideoPlayer/plugin.js b/src/plugins/htmlVideoPlayer/plugin.js index 9e5a5865ee..2283fc54c0 100644 --- a/src/plugins/htmlVideoPlayer/plugin.js +++ b/src/plugins/htmlVideoPlayer/plugin.js @@ -1664,7 +1664,13 @@ export class HtmlVideoPlayer { } } - return Promise.resolve(dlg.querySelector('video')); + const videoElement = dlg.querySelector('video'); + if (options.backdropUrl) { + // update backdrop image + videoElement.poster = options.backdropUrl; + } + + return Promise.resolve(videoElement); } }