From 41c26d154aa26a1abe34c8cffc82cec0da35b42f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 24 Oct 2022 10:08:17 +0200 Subject: Fix reloading new live session in embed --- client/src/standalone/videos/shared/player-html.ts | 3 +++ 1 file changed, 3 insertions(+) (limited to 'client/src/standalone') diff --git a/client/src/standalone/videos/shared/player-html.ts b/client/src/standalone/videos/shared/player-html.ts index 61231d2cb..d93678c10 100644 --- a/client/src/standalone/videos/shared/player-html.ts +++ b/client/src/standalone/videos/shared/player-html.ts @@ -79,7 +79,10 @@ export class PlayerHTML { } removeInformation () { + if (!this.informationElement) return + this.removeElement(this.informationElement) + this.informationElement = undefined } private getPlaceholderElement () { -- cgit v1.2.3 From b1934b7e9cdece7c0c38e05b0f905dc2ccab9167 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 24 Oct 2022 10:32:35 +0200 Subject: Fix broken player on live reload --- client/src/standalone/videos/embed.ts | 1 + client/src/standalone/videos/shared/live-manager.ts | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'client/src/standalone') diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts index 5384ada1c..451e54840 100644 --- a/client/src/standalone/videos/embed.ts +++ b/client/src/standalone/videos/embed.ts @@ -259,6 +259,7 @@ export class PeerTubeEmbed { if (this.player) { this.player.dispose() + this.player = undefined alreadyHadPlayer = true } diff --git a/client/src/standalone/videos/shared/live-manager.ts b/client/src/standalone/videos/shared/live-manager.ts index 422d39793..ec11d0b61 100644 --- a/client/src/standalone/videos/shared/live-manager.ts +++ b/client/src/standalone/videos/shared/live-manager.ts @@ -6,6 +6,8 @@ import { Translations } from './translations' export class LiveManager { private liveSocket: Socket + private listeners = new Map void>() + constructor ( private readonly playerHTML: PlayerHTML ) { @@ -26,18 +28,26 @@ export class LiveManager { this.liveSocket = io(window.location.origin + '/live-videos') } - this.liveSocket.on('state-change', (payload: LiveVideoEventPayload) => { + const listener = (payload: LiveVideoEventPayload) => { if (payload.state === VideoState.PUBLISHED) { this.playerHTML.removeInformation() onPublishedVideo() return } - }) + } + + this.liveSocket.on('state-change', listener) + this.listeners.set(video.uuid, listener) this.liveSocket.emit('subscribe', { videoId: video.id }) } stopListeningForChanges (video: VideoDetails) { + const listener = this.listeners.get(video.uuid) + if (listener) { + this.liveSocket.off('state-change', listener) + } + this.liveSocket.emit('unsubscribe', { videoId: video.id }) } -- cgit v1.2.3