diff options
author | Chocobozzz <me@florianbigard.com> | 2022-11-15 08:55:27 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-11-15 10:50:57 +0100 |
commit | c2419476302b20e9fe3708d7a0a889ae18c95c1b (patch) | |
tree | 3276a4b6979ce3bba80f776f116d7e5cc55863db /client/src/standalone/videos/embed.ts | |
parent | 90dbc73132f22888a60628d921c92f938499bd7b (diff) | |
download | PeerTube-c2419476302b20e9fe3708d7a0a889ae18c95c1b.tar.gz PeerTube-c2419476302b20e9fe3708d7a0a889ae18c95c1b.tar.zst PeerTube-c2419476302b20e9fe3708d7a0a889ae18c95c1b.zip |
Correctly terminate an ended live
Diffstat (limited to 'client/src/standalone/videos/embed.ts')
-rw-r--r-- | client/src/standalone/videos/embed.ts | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts index 356f149c0..2b826b9a2 100644 --- a/client/src/standalone/videos/embed.ts +++ b/client/src/standalone/videos/embed.ts | |||
@@ -3,12 +3,12 @@ import '../../assets/player/shared/dock/peertube-dock-component' | |||
3 | import '../../assets/player/shared/dock/peertube-dock-plugin' | 3 | import '../../assets/player/shared/dock/peertube-dock-plugin' |
4 | import videojs from 'video.js' | 4 | import videojs from 'video.js' |
5 | import { peertubeTranslate } from '../../../../shared/core-utils/i18n' | 5 | import { peertubeTranslate } from '../../../../shared/core-utils/i18n' |
6 | import { HTMLServerConfig, ResultList, VideoDetails, VideoPlaylist, VideoPlaylistElement } from '../../../../shared/models' | 6 | import { HTMLServerConfig, ResultList, VideoDetails, VideoPlaylist, VideoPlaylistElement, VideoState } from '../../../../shared/models' |
7 | import { PeertubePlayerManager } from '../../assets/player' | 7 | import { PeertubePlayerManager } from '../../assets/player' |
8 | import { TranslationsManager } from '../../assets/player/translations-manager' | 8 | import { TranslationsManager } from '../../assets/player/translations-manager' |
9 | import { getParamString, logger, videoRequiresAuth } from '../../root-helpers' | 9 | import { getParamString, logger, videoRequiresAuth } from '../../root-helpers' |
10 | import { PeerTubeEmbedApi } from './embed-api' | 10 | import { PeerTubeEmbedApi } from './embed-api' |
11 | import { AuthHTTP, LiveManager, PeerTubePlugin, PlayerManagerOptions, PlaylistFetcher, PlaylistTracker, VideoFetcher } from './shared' | 11 | import { AuthHTTP, LiveManager, PeerTubePlugin, PlayerManagerOptions, PlaylistFetcher, PlaylistTracker, Translations, VideoFetcher } from './shared' |
12 | import { PlayerHTML } from './shared/player-html' | 12 | import { PlayerHTML } from './shared/player-html' |
13 | 13 | ||
14 | export class PeerTubeEmbed { | 14 | export class PeerTubeEmbed { |
@@ -251,18 +251,25 @@ export class PeerTubeEmbed { | |||
251 | }) | 251 | }) |
252 | } | 252 | } |
253 | 253 | ||
254 | this.peertubePlugin.getPluginsManager().runHook('action:embed.player.loaded', undefined, { player: this.player, videojs, video }) | ||
255 | |||
256 | if (video.isLive) { | 254 | if (video.isLive) { |
257 | this.liveManager.displayInfoAndListenForChanges({ | 255 | this.liveManager.listenForChanges({ |
258 | video, | 256 | video, |
259 | translations, | ||
260 | onPublishedVideo: () => { | 257 | onPublishedVideo: () => { |
261 | this.liveManager.stopListeningForChanges(video) | 258 | this.liveManager.stopListeningForChanges(video) |
262 | this.loadVideoAndBuildPlayer(video.uuid) | 259 | this.loadVideoAndBuildPlayer(video.uuid) |
263 | } | 260 | } |
264 | }) | 261 | }) |
262 | |||
263 | if (video.state.id === VideoState.WAITING_FOR_LIVE || video.state.id === VideoState.LIVE_ENDED) { | ||
264 | this.liveManager.displayInfo({ state: video.state.id, translations }) | ||
265 | |||
266 | this.disablePlayer() | ||
267 | } else { | ||
268 | this.correctlyHandleLiveEnding(translations) | ||
269 | } | ||
265 | } | 270 | } |
271 | |||
272 | this.peertubePlugin.getPluginsManager().runHook('action:embed.player.loaded', undefined, { player: this.player, videojs, video }) | ||
266 | } | 273 | } |
267 | 274 | ||
268 | private resetPlayerElement () { | 275 | private resetPlayerElement () { |
@@ -351,6 +358,31 @@ export class PeerTubeEmbed { | |||
351 | private isPlaylistEmbed () { | 358 | private isPlaylistEmbed () { |
352 | return window.location.pathname.split('/')[1] === 'video-playlists' | 359 | return window.location.pathname.split('/')[1] === 'video-playlists' |
353 | } | 360 | } |
361 | |||
362 | // --------------------------------------------------------------------------- | ||
363 | |||
364 | private correctlyHandleLiveEnding (translations: Translations) { | ||
365 | this.player.one('ended', () => { | ||
366 | // Display the live ended information | ||
367 | this.liveManager.displayInfo({ state: VideoState.LIVE_ENDED, translations }) | ||
368 | |||
369 | this.disablePlayer() | ||
370 | }) | ||
371 | } | ||
372 | |||
373 | private disablePlayer () { | ||
374 | if (this.player.isFullscreen()) { | ||
375 | this.player.exitFullscreen() | ||
376 | } | ||
377 | |||
378 | // Disable player | ||
379 | this.player.hasStarted(false) | ||
380 | this.player.removeClass('vjs-has-autoplay') | ||
381 | this.player.bigPlayButton.hide(); | ||
382 | |||
383 | (this.player.el() as HTMLElement).style.pointerEvents = 'none' | ||
384 | } | ||
385 | |||
354 | } | 386 | } |
355 | 387 | ||
356 | PeerTubeEmbed.main() | 388 | PeerTubeEmbed.main() |