Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Fix stale poster on video change

Chocobozzz7bebbe146b1e
diff --git a/client/src/standalone/player/src/peertube-player.ts b/client/src/standalone/player/src/peertube-player.ts
index 4e1bc8bc5c..0406e0724e 100644
--- a/client/src/standalone/player/src/peertube-player.ts
+++ b/client/src/standalone/player/src/peertube-player.ts
@@ -403,10 +403,6 @@ export class PeerTubePlayer {
}
private getVideojsOptions (): VideojsPlayerOptions {
- const posterWidth = this.options.playerElement().clientWidth || this.getScreenWidth()
-
- const poster = findAppropriateThumbnail(this.currentLoadOptions.thumbnails, posterWidth, '16:9')?.fileUrl || ''
-
const html5 = {
preloadTextTracks: false,
// Prevent a bug on iOS where the text tracks added by peertube plugin are removed on play
@@ -414,6 +410,12 @@ export class PeerTubePlayer {
nativeTextTracks: false
}
+ const getPoster = () => {
+ const posterWidth = this.options.playerElement().clientWidth || this.getScreenWidth()
+
+ return findAppropriateThumbnail(this.currentLoadOptions.thumbnails, posterWidth, '16:9')?.fileUrl || ''
+ }
+
const plugins: VideoJSPluginOptions = {
peertube: {
hasAutoplay: () => this.getAutoPlayValue(this.currentLoadOptions.autoplay),
@@ -438,7 +440,7 @@ export class PeerTubePlayer {
videoRatio: () => this.currentLoadOptions.videoRatio,
- poster: () => poster,
+ poster: () => getPoster(),
playbackRate: this.options.playbackRate,
autoPlayerRatio: this.options.autoPlayerRatio
@@ -476,7 +478,7 @@ export class PeerTubePlayer {
autoplay: this.getAutoPlayValue(this.currentLoadOptions.autoplay),
- poster,
+ poster: getPoster(),
preload: 'none' as 'none',
inactivityTimeout: this.options.inactivityTimeout,