ActivityPub-federated video streaming platform using P2P directly in your web browser
Fix invalid width error in embed
Chocobozzzab44a031416a
diff --git a/client/src/standalone/player/src/peertube-player.ts b/client/src/standalone/player/src/peertube-player.tsindex 61ccb0ac35..4e1bc8bc5c 100644--- a/client/src/standalone/player/src/peertube-player.ts+++ b/client/src/standalone/player/src/peertube-player.ts@@ -151,15 +151,11 @@ export class PeerTubePlayer {}setPoster (thumbnails: Thumbnail[]) {- // window.innerWidth returns sometimes 0 on firefox if we load the page in background- // So we fallback to screen.availWidth which seems more reliable, at least on desktop- const getScreenWidth = () => window.innerWidth || screen.availWidth-// Use HTML video element to display posterif (!this.player) {const playerEl = this.options.playerElement()- const width = playerEl.clientWidth || getScreenWidth()+ const width = playerEl.clientWidth || this.getScreenWidth()this.options.playerElement().poster = findAppropriateThumbnail(thumbnails, width, '16:9')?.fileUrl || ''return@@ -167,8 +163,7 @@ export class PeerTubePlayer {// Prefer using player poster APIif (this.player) {- //- const width = this.player.el().clientWidth || getScreenWidth()+ const width = this.player.el().clientWidth || this.getScreenWidth()this.player.poster(findAppropriateThumbnail(thumbnails, width, '16:9')?.fileUrl || '')}@@ -408,7 +403,7 @@ export class PeerTubePlayer {}private getVideojsOptions (): VideojsPlayerOptions {- const posterWidth = this.options.playerElement().clientWidth || window.innerWidth+ const posterWidth = this.options.playerElement().clientWidth || this.getScreenWidth()const poster = findAppropriateThumbnail(this.currentLoadOptions.thumbnails, posterWidth, '16:9')?.fileUrl || ''@@ -603,4 +598,11 @@ export class PeerTubePlayer {return { content }}++ // window.innerWidth returns sometimes 0 on Firefox if we load the page in background+ // So we also test screen.availWidth which seems more reliable, at least on desktop+ // Finally fallback to default embed width if both are 0 (can happen when the embed is hidden or collapsed)+ private getScreenWidth () {+ return window.innerWidth || screen.availWidth || 560+ }}