aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/+video-watch/video-watch-playlist.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-playlist.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-playlist.component.ts')
-rw-r--r--client/src/app/videos/+video-watch/video-watch-playlist.component.ts36
1 files changed, 23 insertions, 13 deletions
diff --git a/client/src/app/videos/+video-watch/video-watch-playlist.component.ts b/client/src/app/videos/+video-watch/video-watch-playlist.component.ts
index c6b04fd4b..c5ed36000 100644
--- a/client/src/app/videos/+video-watch/video-watch-playlist.component.ts
+++ b/client/src/app/videos/+video-watch/video-watch-playlist.component.ts
@@ -44,11 +44,13 @@ export class VideoWatchPlaylistComponent {
44 private videoPlaylist: VideoPlaylistService, 44 private videoPlaylist: VideoPlaylistService,
45 private router: Router 45 private router: Router
46 ) { 46 ) {
47 // defaults to true
47 this.autoPlayNextVideoPlaylist = this.auth.isLoggedIn() 48 this.autoPlayNextVideoPlaylist = this.auth.isLoggedIn()
48 ? this.auth.getUser().autoPlayNextVideoPlaylist 49 ? this.auth.getUser().autoPlayNextVideoPlaylist
49 : peertubeLocalStorage.getItem(VideoWatchPlaylistComponent.LOCAL_STORAGE_AUTO_PLAY_NEXT_VIDEO_PLAYLIST) !== 'false' 50 : peertubeLocalStorage.getItem(VideoWatchPlaylistComponent.LOCAL_STORAGE_AUTO_PLAY_NEXT_VIDEO_PLAYLIST) !== 'false'
50 this.setAutoPlayNextVideoPlaylistSwitchText() 51 this.setAutoPlayNextVideoPlaylistSwitchText()
51 52
53 // defaults to false
52 this.loopPlaylist = peertubeSessionStorage.getItem(VideoWatchPlaylistComponent.SESSION_STORAGE_AUTO_PLAY_NEXT_VIDEO_PLAYLIST) === 'true' 54 this.loopPlaylist = peertubeSessionStorage.getItem(VideoWatchPlaylistComponent.SESSION_STORAGE_AUTO_PLAY_NEXT_VIDEO_PLAYLIST) === 'true'
53 this.setLoopPlaylistSwitchText() 55 this.setLoopPlaylistSwitchText()
54 } 56 }
@@ -127,23 +129,31 @@ export class VideoWatchPlaylistComponent {
127 this.onPlaylistVideosNearOfBottom() 129 this.onPlaylistVideosNearOfBottom()
128 } 130 }
129 131
130 navigateToNextPlaylistVideo (_next: VideoPlaylistElement = null) { 132 findNextPlaylistVideo (position = this.currentPlaylistPosition): VideoPlaylistElement {
131 if (this.currentPlaylistPosition < this.playlistPagination.totalItems) { 133 if (this.currentPlaylistPosition >= this.playlistPagination.totalItems) {
132 const next = _next || this.playlistElements.find(e => e.position === this.currentPlaylistPosition + 1) 134 // we have reached the end of the playlist: either loop or stop
133 135 if (this.loopPlaylist) {
134 if (!next || !next.video) { 136 this.currentPlaylistPosition = position = 0
135 this.currentPlaylistPosition++ 137 } else {
136 this.navigateToNextPlaylistVideo()
137 return 138 return
138 } 139 }
140 }
141
142 const next = this.playlistElements.find(e => e.position === position)
139 143
140 const start = next.startTimestamp 144 if (!next || !next.video) {
141 const stop = next.stopTimestamp 145 return this.findNextPlaylistVideo(position + 1)
142 this.router.navigate([],{ queryParams: { videoId: next.video.uuid, start, stop } })
143 } else if (this.loopPlaylist) {
144 this.currentPlaylistPosition = 0
145 this.navigateToNextPlaylistVideo(this.playlistElements.find(e => e.position === this.currentPlaylistPosition))
146 } 146 }
147
148 return next
149 }
150
151 navigateToNextPlaylistVideo () {
152 const next = this.findNextPlaylistVideo(this.currentPlaylistPosition + 1)
153 if (!next) return
154 const start = next.startTimestamp
155 const stop = next.stopTimestamp
156 this.router.navigate([],{ queryParams: { videoId: next.video.uuid, start, stop } })
147 } 157 }
148 158
149 switchAutoPlayNextVideoPlaylist () { 159 switchAutoPlayNextVideoPlaylist () {