aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/standalone/videos/embed.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-10-12 16:09:02 +0200
committerChocobozzz <chocobozzz@cpy.re>2022-10-24 14:48:24 +0200
commit3545e72c686ff1725bbdfd8d16d693e2f4aa75a3 (patch)
treee7f1d12ef5dae1e1142c3a8d0b681c1dbbb0de10 /client/src/standalone/videos/embed.ts
parent38a3ccc7f8ad0ea94362b58c732af7c387ab46be (diff)
downloadPeerTube-3545e72c686ff1725bbdfd8d16d693e2f4aa75a3.tar.gz
PeerTube-3545e72c686ff1725bbdfd8d16d693e2f4aa75a3.tar.zst
PeerTube-3545e72c686ff1725bbdfd8d16d693e2f4aa75a3.zip
Put private videos under a specific subdirectory
Diffstat (limited to 'client/src/standalone/videos/embed.ts')
-rw-r--r--client/src/standalone/videos/embed.ts22
1 files changed, 14 insertions, 8 deletions
diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts
index 451e54840..c6160151a 100644
--- a/client/src/standalone/videos/embed.ts
+++ b/client/src/standalone/videos/embed.ts
@@ -6,7 +6,7 @@ import { peertubeTranslate } from '../../../../shared/core-utils/i18n'
6import { HTMLServerConfig, LiveVideo, ResultList, VideoDetails, VideoPlaylist, VideoPlaylistElement } from '../../../../shared/models' 6import { HTMLServerConfig, LiveVideo, ResultList, VideoDetails, VideoPlaylist, VideoPlaylistElement } from '../../../../shared/models'
7import { PeertubePlayerManager } from '../../assets/player' 7import { PeertubePlayerManager } from '../../assets/player'
8import { TranslationsManager } from '../../assets/player/translations-manager' 8import { TranslationsManager } from '../../assets/player/translations-manager'
9import { getParamString, logger } from '../../root-helpers' 9import { getParamString, logger, videoRequiresAuth } from '../../root-helpers'
10import { PeerTubeEmbedApi } from './embed-api' 10import { PeerTubeEmbedApi } from './embed-api'
11import { AuthHTTP, LiveManager, PeerTubePlugin, PlayerManagerOptions, PlaylistFetcher, PlaylistTracker, VideoFetcher } from './shared' 11import { AuthHTTP, LiveManager, PeerTubePlugin, PlayerManagerOptions, PlaylistFetcher, PlaylistTracker, VideoFetcher } from './shared'
12import { PlayerHTML } from './shared/player-html' 12import { PlayerHTML } from './shared/player-html'
@@ -167,22 +167,25 @@ export class PeerTubeEmbed {
167 private async buildVideoPlayer (videoResponse: Response, captionsPromise: Promise<Response>) { 167 private async buildVideoPlayer (videoResponse: Response, captionsPromise: Promise<Response>) {
168 const alreadyHadPlayer = this.resetPlayerElement() 168 const alreadyHadPlayer = this.resetPlayerElement()
169 169
170 const videoInfoPromise: Promise<{ video: VideoDetails, live?: LiveVideo }> = videoResponse.json() 170 const videoInfoPromise = videoResponse.json()
171 .then((videoInfo: VideoDetails) => { 171 .then(async (videoInfo: VideoDetails) => {
172 this.playerManagerOptions.loadParams(this.config, videoInfo) 172 this.playerManagerOptions.loadParams(this.config, videoInfo)
173 173
174 if (!alreadyHadPlayer && !this.playerManagerOptions.hasAutoplay()) { 174 if (!alreadyHadPlayer && !this.playerManagerOptions.hasAutoplay()) {
175 this.playerHTML.buildPlaceholder(videoInfo) 175 this.playerHTML.buildPlaceholder(videoInfo)
176 } 176 }
177 const live = videoInfo.isLive
178 ? await this.videoFetcher.loadLive(videoInfo)
179 : undefined
177 180
178 if (!videoInfo.isLive) { 181 const videoFileToken = videoRequiresAuth(videoInfo)
179 return { video: videoInfo } 182 ? await this.videoFetcher.loadVideoToken(videoInfo)
180 } 183 : undefined
181 184
182 return this.videoFetcher.loadVideoWithLive(videoInfo) 185 return { live, video: videoInfo, videoFileToken }
183 }) 186 })
184 187
185 const [ { video, live }, translations, captionsResponse, PeertubePlayerManagerModule ] = await Promise.all([ 188 const [ { video, live, videoFileToken }, translations, captionsResponse, PeertubePlayerManagerModule ] = await Promise.all([
186 videoInfoPromise, 189 videoInfoPromise,
187 this.translationsPromise, 190 this.translationsPromise,
188 captionsPromise, 191 captionsPromise,
@@ -200,6 +203,9 @@ export class PeerTubeEmbed {
200 translations, 203 translations,
201 serverConfig: this.config, 204 serverConfig: this.config,
202 205
206 authorizationHeader: () => this.http.getHeaderTokenValue(),
207 videoFileToken: () => videoFileToken,
208
203 onVideoUpdate: (uuid: string) => this.loadVideoAndBuildPlayer(uuid), 209 onVideoUpdate: (uuid: string) => this.loadVideoAndBuildPlayer(uuid),
204 210
205 playlistTracker: this.playlistTracker, 211 playlistTracker: this.playlistTracker,