aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/standalone/videos/embed.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-12-14 14:06:12 +0100
committerChocobozzz <me@florianbigard.com>2022-12-14 14:06:12 +0100
commit7dcd45a9a289c2da38eafd9a0b293453981b0da4 (patch)
tree6cced9f152da0d7b7c3f80f28bb6d9e2532be674 /client/src/standalone/videos/embed.ts
parent21e73020142635f0b1b2c8694a6b5164437954b9 (diff)
downloadPeerTube-7dcd45a9a289c2da38eafd9a0b293453981b0da4.tar.gz
PeerTube-7dcd45a9a289c2da38eafd9a0b293453981b0da4.tar.zst
PeerTube-7dcd45a9a289c2da38eafd9a0b293453981b0da4.zip
Don't not autoplay live without autoplay setting
Diffstat (limited to 'client/src/standalone/videos/embed.ts')
-rw-r--r--client/src/standalone/videos/embed.ts29
1 files changed, 13 insertions, 16 deletions
diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts
index 5bb3b43c2..d268f4762 100644
--- a/client/src/standalone/videos/embed.ts
+++ b/client/src/standalone/videos/embed.ts
@@ -90,7 +90,7 @@ export class PeerTubeEmbed {
90 90
91 if (!videoId) return 91 if (!videoId) return
92 92
93 return this.loadVideoAndBuildPlayer({ uuid: videoId, forceAutoplay: false }) 93 return this.loadVideoAndBuildPlayer({ uuid: videoId, autoplayFromPreviousVideo: false, forceAutoplay: false })
94 } 94 }
95 95
96 private async initPlaylist () { 96 private async initPlaylist () {
@@ -147,7 +147,7 @@ export class PeerTubeEmbed {
147 147
148 this.playlistTracker.setCurrentElement(next) 148 this.playlistTracker.setCurrentElement(next)
149 149
150 return this.loadVideoAndBuildPlayer({ uuid: next.video.uuid, forceAutoplay: false }) 150 return this.loadVideoAndBuildPlayer({ uuid: next.video.uuid, autoplayFromPreviousVideo: true, forceAutoplay: false })
151 } 151 }
152 152
153 async playPreviousPlaylistVideo () { 153 async playPreviousPlaylistVideo () {
@@ -159,7 +159,7 @@ export class PeerTubeEmbed {
159 159
160 this.playlistTracker.setCurrentElement(previous) 160 this.playlistTracker.setCurrentElement(previous)
161 161
162 await this.loadVideoAndBuildPlayer({ uuid: previous.video.uuid, forceAutoplay: false }) 162 await this.loadVideoAndBuildPlayer({ uuid: previous.video.uuid, autoplayFromPreviousVideo: true, forceAutoplay: false })
163 } 163 }
164 164
165 getCurrentPlaylistPosition () { 165 getCurrentPlaylistPosition () {
@@ -170,14 +170,15 @@ export class PeerTubeEmbed {
170 170
171 private async loadVideoAndBuildPlayer (options: { 171 private async loadVideoAndBuildPlayer (options: {
172 uuid: string 172 uuid: string
173 autoplayFromPreviousVideo: boolean
173 forceAutoplay: boolean 174 forceAutoplay: boolean
174 }) { 175 }) {
175 const { uuid, forceAutoplay } = options 176 const { uuid, autoplayFromPreviousVideo, forceAutoplay } = options
176 177
177 try { 178 try {
178 const { videoResponse, captionsPromise } = await this.videoFetcher.loadVideo(uuid) 179 const { videoResponse, captionsPromise } = await this.videoFetcher.loadVideo(uuid)
179 180
180 return this.buildVideoPlayer({ videoResponse, captionsPromise, forceAutoplay }) 181 return this.buildVideoPlayer({ videoResponse, captionsPromise, autoplayFromPreviousVideo, forceAutoplay })
181 } catch (err) { 182 } catch (err) {
182 this.playerHTML.displayError(err.message, await this.translationsPromise) 183 this.playerHTML.displayError(err.message, await this.translationsPromise)
183 } 184 }
@@ -186,17 +187,18 @@ export class PeerTubeEmbed {
186 private async buildVideoPlayer (options: { 187 private async buildVideoPlayer (options: {
187 videoResponse: Response 188 videoResponse: Response
188 captionsPromise: Promise<Response> 189 captionsPromise: Promise<Response>
190 autoplayFromPreviousVideo: boolean
189 forceAutoplay: boolean 191 forceAutoplay: boolean
190 }) { 192 }) {
191 const { videoResponse, captionsPromise, forceAutoplay } = options 193 const { videoResponse, captionsPromise, autoplayFromPreviousVideo, forceAutoplay } = options
192 194
193 const alreadyHadPlayer = this.resetPlayerElement() 195 this.resetPlayerElement()
194 196
195 const videoInfoPromise = videoResponse.json() 197 const videoInfoPromise = videoResponse.json()
196 .then(async (videoInfo: VideoDetails) => { 198 .then(async (videoInfo: VideoDetails) => {
197 this.playerManagerOptions.loadParams(this.config, videoInfo) 199 this.playerManagerOptions.loadParams(this.config, videoInfo)
198 200
199 if (!alreadyHadPlayer && !this.playerManagerOptions.hasAutoplay()) { 201 if (!autoplayFromPreviousVideo && !this.playerManagerOptions.hasAutoplay()) {
200 this.playerHTML.buildPlaceholder(videoInfo) 202 this.playerHTML.buildPlaceholder(videoInfo)
201 } 203 }
202 const live = videoInfo.isLive 204 const live = videoInfo.isLive
@@ -224,14 +226,14 @@ export class PeerTubeEmbed {
224 const playerOptions = await this.playerManagerOptions.getPlayerOptions({ 226 const playerOptions = await this.playerManagerOptions.getPlayerOptions({
225 video, 227 video,
226 captionsResponse, 228 captionsResponse,
227 alreadyHadPlayer, 229 autoplayFromPreviousVideo,
228 translations, 230 translations,
229 serverConfig: this.config, 231 serverConfig: this.config,
230 232
231 authorizationHeader: () => this.http.getHeaderTokenValue(), 233 authorizationHeader: () => this.http.getHeaderTokenValue(),
232 videoFileToken: () => videoFileToken, 234 videoFileToken: () => videoFileToken,
233 235
234 onVideoUpdate: (uuid: string) => this.loadVideoAndBuildPlayer({ uuid, forceAutoplay: false }), 236 onVideoUpdate: (uuid: string) => this.loadVideoAndBuildPlayer({ uuid, autoplayFromPreviousVideo: true, forceAutoplay: false }),
235 237
236 playlistTracker: this.playlistTracker, 238 playlistTracker: this.playlistTracker,
237 playNextPlaylistVideo: () => this.playNextPlaylistVideo(), 239 playNextPlaylistVideo: () => this.playNextPlaylistVideo(),
@@ -277,7 +279,7 @@ export class PeerTubeEmbed {
277 video, 279 video,
278 onPublishedVideo: () => { 280 onPublishedVideo: () => {
279 this.liveManager.stopListeningForChanges(video) 281 this.liveManager.stopListeningForChanges(video)
280 this.loadVideoAndBuildPlayer({ uuid: video.uuid, forceAutoplay: true }) 282 this.loadVideoAndBuildPlayer({ uuid: video.uuid, autoplayFromPreviousVideo: false, forceAutoplay: true })
281 } 283 }
282 }) 284 })
283 285
@@ -294,12 +296,9 @@ export class PeerTubeEmbed {
294 } 296 }
295 297
296 private resetPlayerElement () { 298 private resetPlayerElement () {
297 let alreadyHadPlayer = false
298
299 if (this.player) { 299 if (this.player) {
300 this.player.dispose() 300 this.player.dispose()
301 this.player = undefined 301 this.player = undefined
302 alreadyHadPlayer = true
303 } 302 }
304 303
305 const playerElement = document.createElement('video') 304 const playerElement = document.createElement('video')
@@ -308,8 +307,6 @@ export class PeerTubeEmbed {
308 307
309 this.playerHTML.setPlayerElement(playerElement) 308 this.playerHTML.setPlayerElement(playerElement)
310 this.playerHTML.addPlayerElementToDOM() 309 this.playerHTML.addPlayerElementToDOM()
311
312 return alreadyHadPlayer
313 } 310 }
314 311
315 private async buildPlayerPlaylistUpnext () { 312 private async buildPlayerPlaylistUpnext () {