aboutsummaryrefslogtreecommitdiffhomepage
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/src/standalone/videos/embed.ts1
-rw-r--r--client/src/standalone/videos/shared/live-manager.ts14
2 files changed, 13 insertions, 2 deletions
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 {
259 259
260 if (this.player) { 260 if (this.player) {
261 this.player.dispose() 261 this.player.dispose()
262 this.player = undefined
262 alreadyHadPlayer = true 263 alreadyHadPlayer = true
263 } 264 }
264 265
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'
6export class LiveManager { 6export class LiveManager {
7 private liveSocket: Socket 7 private liveSocket: Socket
8 8
9 private listeners = new Map<string, (payload: LiveVideoEventPayload) => void>()
10
9 constructor ( 11 constructor (
10 private readonly playerHTML: PlayerHTML 12 private readonly playerHTML: PlayerHTML
11 ) { 13 ) {
@@ -26,18 +28,26 @@ export class LiveManager {
26 this.liveSocket = io(window.location.origin + '/live-videos') 28 this.liveSocket = io(window.location.origin + '/live-videos')
27 } 29 }
28 30
29 this.liveSocket.on('state-change', (payload: LiveVideoEventPayload) => { 31 const listener = (payload: LiveVideoEventPayload) => {
30 if (payload.state === VideoState.PUBLISHED) { 32 if (payload.state === VideoState.PUBLISHED) {
31 this.playerHTML.removeInformation() 33 this.playerHTML.removeInformation()
32 onPublishedVideo() 34 onPublishedVideo()
33 return 35 return
34 } 36 }
35 }) 37 }
38
39 this.liveSocket.on('state-change', listener)
40 this.listeners.set(video.uuid, listener)
36 41
37 this.liveSocket.emit('subscribe', { videoId: video.id }) 42 this.liveSocket.emit('subscribe', { videoId: video.id })
38 } 43 }
39 44
40 stopListeningForChanges (video: VideoDetails) { 45 stopListeningForChanges (video: VideoDetails) {
46 const listener = this.listeners.get(video.uuid)
47 if (listener) {
48 this.liveSocket.off('state-change', listener)
49 }
50
41 this.liveSocket.emit('unsubscribe', { videoId: video.id }) 51 this.liveSocket.emit('unsubscribe', { videoId: video.id })
42 } 52 }
43 53