aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+videos/+video-watch
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-11-15 11:57:49 +0100
committerChocobozzz <me@florianbigard.com>2022-11-15 11:57:49 +0100
commit59a643aa5cf6775d27dfcc147b19c4537292d53c (patch)
tree74bc87e2f0f5581306c8ea9dd1f8acf05833a74a /client/src/app/+videos/+video-watch
parentc2419476302b20e9fe3708d7a0a889ae18c95c1b (diff)
downloadPeerTube-59a643aa5cf6775d27dfcc147b19c4537292d53c.tar.gz
PeerTube-59a643aa5cf6775d27dfcc147b19c4537292d53c.tar.zst
PeerTube-59a643aa5cf6775d27dfcc147b19c4537292d53c.zip
Force autoplay when live starts
Using the mute
Diffstat (limited to 'client/src/app/+videos/+video-watch')
-rw-r--r--client/src/app/+videos/+video-watch/video-watch.component.ts42
1 files changed, 32 insertions, 10 deletions
diff --git a/client/src/app/+videos/+video-watch/video-watch.component.ts b/client/src/app/+videos/+video-watch/video-watch.component.ts
index 983a27e11..94853423b 100644
--- a/client/src/app/+videos/+video-watch/video-watch.component.ts
+++ b/client/src/app/+videos/+video-watch/video-watch.component.ts
@@ -180,7 +180,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
180 } 180 }
181 181
182 onPlaylistVideoFound (videoId: string) { 182 onPlaylistVideoFound (videoId: string) {
183 this.loadVideo(videoId) 183 this.loadVideo({ videoId, forceAutoplay: false })
184 } 184 }
185 185
186 onPlaylistNoVideoFound () { 186 onPlaylistNoVideoFound () {
@@ -212,7 +212,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
212 private loadRouteParams () { 212 private loadRouteParams () {
213 this.paramsSub = this.route.params.subscribe(routeParams => { 213 this.paramsSub = this.route.params.subscribe(routeParams => {
214 const videoId = routeParams['videoId'] 214 const videoId = routeParams['videoId']
215 if (videoId) return this.loadVideo(videoId) 215 if (videoId) return this.loadVideo({ videoId, forceAutoplay: false })
216 216
217 const playlistId = routeParams['playlistId'] 217 const playlistId = routeParams['playlistId']
218 if (playlistId) return this.loadPlaylist(playlistId) 218 if (playlistId) return this.loadPlaylist(playlistId)
@@ -240,7 +240,12 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
240 }) 240 })
241 } 241 }
242 242
243 private loadVideo (videoId: string) { 243 private loadVideo (options: {
244 videoId: string
245 forceAutoplay: boolean
246 }) {
247 const { videoId, forceAutoplay } = options
248
244 if (this.isSameElement(this.video, videoId)) return 249 if (this.isSameElement(this.video, videoId)) return
245 250
246 if (this.player) this.player.pause() 251 if (this.player) this.player.pause()
@@ -293,8 +298,15 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
293 peertubeLink: false 298 peertubeLink: false
294 } 299 }
295 300
296 this.onVideoFetched({ video, live, videoCaptions: captionsResult.data, videoFileToken, loggedInOrAnonymousUser, urlOptions }) 301 this.onVideoFetched({
297 .catch(err => this.handleGlobalError(err)) 302 video,
303 live,
304 videoCaptions: captionsResult.data,
305 videoFileToken,
306 loggedInOrAnonymousUser,
307 urlOptions,
308 forceAutoplay
309 }).catch(err => this.handleGlobalError(err))
298 }, 310 },
299 311
300 error: err => this.handleRequestError(err) 312 error: err => this.handleRequestError(err)
@@ -370,8 +382,9 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
370 382
371 urlOptions: URLOptions 383 urlOptions: URLOptions
372 loggedInOrAnonymousUser: User 384 loggedInOrAnonymousUser: User
385 forceAutoplay: boolean
373 }) { 386 }) {
374 const { video, live, videoCaptions, urlOptions, videoFileToken, loggedInOrAnonymousUser } = options 387 const { video, live, videoCaptions, urlOptions, videoFileToken, loggedInOrAnonymousUser, forceAutoplay } = options
375 388
376 this.subscribeToLiveEventsIfNeeded(this.video, video) 389 this.subscribeToLiveEventsIfNeeded(this.video, video)
377 390
@@ -393,7 +406,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
393 if (res === false) return this.location.back() 406 if (res === false) return this.location.back()
394 } 407 }
395 408
396 this.buildPlayer(urlOptions, loggedInOrAnonymousUser) 409 this.buildPlayer({ urlOptions, loggedInOrAnonymousUser, forceAutoplay })
397 .catch(err => logger.error('Cannot build the player', err)) 410 .catch(err => logger.error('Cannot build the player', err))
398 411
399 this.setOpenGraphTags() 412 this.setOpenGraphTags()
@@ -406,7 +419,13 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
406 this.hooks.runAction('action:video-watch.video.loaded', 'video-watch', hookOptions) 419 this.hooks.runAction('action:video-watch.video.loaded', 'video-watch', hookOptions)
407 } 420 }
408 421
409 private async buildPlayer (urlOptions: URLOptions, loggedInOrAnonymousUser: User) { 422 private async buildPlayer (options: {
423 urlOptions: URLOptions
424 loggedInOrAnonymousUser: User
425 forceAutoplay: boolean
426 }) {
427 const { urlOptions, loggedInOrAnonymousUser, forceAutoplay } = options
428
410 // Flush old player if needed 429 // Flush old player if needed
411 this.flushPlayer() 430 this.flushPlayer()
412 431
@@ -430,6 +449,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
430 videoFileToken: this.videoFileToken, 449 videoFileToken: this.videoFileToken,
431 urlOptions, 450 urlOptions,
432 loggedInOrAnonymousUser, 451 loggedInOrAnonymousUser,
452 forceAutoplay,
433 user: this.user 453 user: this.user
434 } 454 }
435 const { playerMode, playerOptions } = await this.hooks.wrapFun( 455 const { playerMode, playerOptions } = await this.hooks.wrapFun(
@@ -581,9 +601,10 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
581 urlOptions: CustomizationOptions & { playerMode: PlayerMode } 601 urlOptions: CustomizationOptions & { playerMode: PlayerMode }
582 602
583 loggedInOrAnonymousUser: User 603 loggedInOrAnonymousUser: User
604 forceAutoplay: boolean
584 user?: AuthUser // Keep for plugins 605 user?: AuthUser // Keep for plugins
585 }) { 606 }) {
586 const { video, liveVideo, videoCaptions, videoFileToken, urlOptions, loggedInOrAnonymousUser } = params 607 const { video, liveVideo, videoCaptions, videoFileToken, urlOptions, loggedInOrAnonymousUser, forceAutoplay } = params
587 608
588 const getStartTime = () => { 609 const getStartTime = () => {
589 const byUrl = urlOptions.startTime !== undefined 610 const byUrl = urlOptions.startTime !== undefined
@@ -615,6 +636,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
615 const options: PeertubePlayerManagerOptions = { 636 const options: PeertubePlayerManagerOptions = {
616 common: { 637 common: {
617 autoplay: this.isAutoplay(), 638 autoplay: this.isAutoplay(),
639 forceAutoplay,
618 p2pEnabled: isP2PEnabled(video, this.serverConfig, loggedInOrAnonymousUser.p2pEnabled), 640 p2pEnabled: isP2PEnabled(video, this.serverConfig, loggedInOrAnonymousUser.p2pEnabled),
619 641
620 hasNextVideo: () => this.hasNextVideo(), 642 hasNextVideo: () => this.hasNextVideo(),
@@ -749,7 +771,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
749 771
750 // Reset to force refresh the video 772 // Reset to force refresh the video
751 this.video = undefined 773 this.video = undefined
752 this.loadVideo(videoUUID) 774 this.loadVideo({ videoId: videoUUID, forceAutoplay: true })
753 } 775 }
754 776
755 private handleLiveViewsChange (newViewers: number) { 777 private handleLiveViewsChange (newViewers: number) {