aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/+video-watch/video-watch.component.ts
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2019-12-12 18:11:55 +0100
committerChocobozzz <chocobozzz@cpy.re>2019-12-13 09:13:43 +0100
commit706c5a4743e1ec29da1a21173da70d39b711fadc (patch)
tree652544d00a0168a1ef5c107bf8fe74216b4ba6fa /client/src/app/videos/+video-watch/video-watch.component.ts
parent1ae3f52a1601c6e54bd5d8239e9f32dac4063fe3 (diff)
downloadPeerTube-706c5a4743e1ec29da1a21173da70d39b711fadc.tar.gz
PeerTube-706c5a4743e1ec29da1a21173da70d39b711fadc.tar.zst
PeerTube-706c5a4743e1ec29da1a21173da70d39b711fadc.zip
change repeat icon and factorize functions
Diffstat (limited to 'client/src/app/videos/+video-watch/video-watch.component.ts')
-rw-r--r--client/src/app/videos/+video-watch/video-watch.component.ts43
1 files changed, 30 insertions, 13 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 aaaa63d4d..890b7996f 100644
--- a/client/src/app/videos/+video-watch/video-watch.component.ts
+++ b/client/src/app/videos/+video-watch/video-watch.component.ts
@@ -267,6 +267,20 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
267 return video.isVideoNSFWForUser(this.user, this.serverService.getConfig()) 267 return video.isVideoNSFWForUser(this.user, this.serverService.getConfig())
268 } 268 }
269 269
270 isAutoPlayEnabled () {
271 return (
272 this.user && this.user.autoPlayNextVideo ||
273 peertubeSessionStorage.getItem(RecommendedVideosComponent.SESSION_STORAGE_AUTO_PLAY_NEXT_VIDEO) === 'true'
274 )
275 }
276
277 isPlaylistAutoPlayEnabled () {
278 return (
279 this.user && this.user.autoPlayNextVideoPlaylist ||
280 peertubeSessionStorage.getItem(VideoWatchPlaylistComponent.SESSION_STORAGE_AUTO_PLAY_NEXT_VIDEO_PLAYLIST) === 'true'
281 )
282 }
283
270 private loadVideo (videoId: string) { 284 private loadVideo (videoId: string) {
271 // Video did not change 285 // Video did not change
272 if (this.video && this.video.uuid === videoId) return 286 if (this.video && this.video.uuid === videoId) return
@@ -436,24 +450,15 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
436 450
437 this.player.one('ended', () => { 451 this.player.one('ended', () => {
438 if (this.playlist) { 452 if (this.playlist) {
439 if ( 453 if (this.isPlaylistAutoPlayEnabled()) this.zone.run(() => this.videoWatchPlaylist.navigateToNextPlaylistVideo())
440 this.user && this.user.autoPlayNextVideoPlaylist || 454 } else if (this.isAutoPlayEnabled()) {
441 peertubeSessionStorage.getItem(VideoWatchPlaylistComponent.SESSION_STORAGE_AUTO_PLAY_NEXT_VIDEO_PLAYLIST) === 'true'
442 ) this.zone.run(() => this.videoWatchPlaylist.navigateToNextPlaylistVideo())
443 } else if (
444 this.user && this.user.autoPlayNextVideo ||
445 peertubeSessionStorage.getItem(RecommendedVideosComponent.SESSION_STORAGE_AUTO_PLAY_NEXT_VIDEO) === 'true'
446 ) {
447 this.zone.run(() => this.autoplayNext()) 455 this.zone.run(() => this.autoplayNext())
448 } 456 }
449 }) 457 })
450 458
451 this.player.one('stopped', () => { 459 this.player.one('stopped', () => {
452 if (this.playlist) { 460 if (this.playlist) {
453 if ( 461 if (this.isPlaylistAutoPlayEnabled()) this.zone.run(() => this.videoWatchPlaylist.navigateToNextPlaylistVideo())
454 this.user && this.user.autoPlayNextVideoPlaylist ||
455 peertubeSessionStorage.getItem(VideoWatchPlaylistComponent.SESSION_STORAGE_AUTO_PLAY_NEXT_VIDEO_PLAYLIST) === 'true'
456 ) this.zone.run(() => this.videoWatchPlaylist.navigateToNextPlaylistVideo())
457 } 462 }
458 }) 463 })
459 464
@@ -568,8 +573,20 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
568 user?: AuthUser 573 user?: AuthUser
569 }) { 574 }) {
570 const { video, videoCaptions, urlOptions, user } = params 575 const { video, videoCaptions, urlOptions, user } = params
576 const getStartTime = () => {
577 const byUrl = urlOptions.startTime !== undefined
578 const byHistory = video.userHistory && !this.playlist
579
580 if (byUrl) {
581 return timeToInt(urlOptions.startTime)
582 } else if (byHistory) {
583 return video.userHistory.currentTime
584 } else {
585 return 0
586 }
587 }
571 588
572 let startTime = timeToInt(urlOptions.startTime) || (video.userHistory && !this.playlist ? video.userHistory.currentTime : 0) 589 let startTime = getStartTime()
573 // If we are at the end of the video, reset the timer 590 // If we are at the end of the video, reset the timer
574 if (video.duration - startTime <= 1) startTime = 0 591 if (video.duration - startTime <= 1) startTime = 0
575 592