ActivityPub-federated video streaming platform using P2P directly in your web browser
Prevent black borders in classic embed
Chocobozzz8295c7df5a5f
diff --git a/client/src/standalone/player/src/peertube-player.ts b/client/src/standalone/player/src/peertube-player.tsindex 538c285f0a..057aaa1bd7 100644--- a/client/src/standalone/player/src/peertube-player.ts+++ b/client/src/standalone/player/src/peertube-player.ts@@ -156,7 +156,7 @@ export class PeerTubePlayer {// Prefer using player poster APIif (this.player) {- this.player.poster(findAppropriateImage(thumbnails, this.player.currentWidth())?.fileUrl || '')+ this.player.poster(findAppropriateImage(thumbnails, this.player.currentWidth() || window.innerWidth)?.fileUrl || '')}this.options.playerElement().poster = ''@@ -391,8 +391,9 @@ export class PeerTubePlayer {}private getVideojsOptions (): VideojsPlayerOptions {- const poster =- findAppropriateImage(this.currentLoadOptions.thumbnails, this.options.playerElement().clientWidth || window.innerWidth)?.fileUrl || ''+ const posterWidth = this.options.playerElement().clientWidth || window.innerWidth++ const poster = findAppropriateImage(this.currentLoadOptions.thumbnails, posterWidth)?.fileUrl || ''const html5 = {preloadTextTracks: false,diff --git a/client/src/standalone/player/src/sass/shared/peertube-skin.scss b/client/src/standalone/player/src/sass/shared/peertube-skin.scssindex 0d8f9af776..b7e33e32f5 100644--- a/client/src/standalone/player/src/sass/shared/peertube-skin.scss+++ b/client/src/standalone/player/src/sass/shared/peertube-skin.scss@@ -109,6 +109,15 @@ body {.vjs-poster {outline: 0;background-size: cover;+ overflow: hidden;++ img {+ // We want the object in contain mode, but the iframe ratio may be a little bit different that the image ratio+ // So we add extra pixels to ensure we don't have black borders+ object-fit: contain;+ width: calc(100% + 2px);+ height: calc(100% + 2px);+ }}// Theater mode is enableddiff --git a/packages/core-utils/src/common/image.ts b/packages/core-utils/src/common/image.tsindex 831f9e11dd..2eb9192cfe 100644--- a/packages/core-utils/src/common/image.ts+++ b/packages/core-utils/src/common/image.ts@@ -1,3 +1,5 @@+import { maxBy } from './array.js'+export function findAppropriateImage<T extends { width: number }> (images: T[], wantedWidth: number) {if (!wantedWidth) throw new Error('Invalid width to find appropriate image')if (!images || images.length === 0) return undefined@@ -10,5 +12,5 @@ export function findAppropriateImage<T extends { width: number }> (images: T[],}}- return candidate || images[0]+ return candidate || maxBy(images, 'width')}