aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src
diff options
context:
space:
mode:
Diffstat (limited to 'client/src')
-rw-r--r--client/src/app/+videos/+video-watch/video-watch-playlist.component.ts27
-rw-r--r--client/src/app/+videos/+video-watch/video-watch.component.ts4
2 files changed, 31 insertions, 0 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 d76d0bbd2..cc908b924 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
@@ -137,6 +137,33 @@ export class VideoWatchPlaylistComponent {
137 this.onPlaylistVideosNearOfBottom(position) 137 this.onPlaylistVideosNearOfBottom(position)
138 } 138 }
139 139
140 findPreviousPlaylistVideo (position = this.currentPlaylistPosition): VideoPlaylistElement {
141 if (this.currentPlaylistPosition <= 1) {
142 // we have reached the top of the playlist: either loop or stop
143 if (this.loopPlaylist) {
144 this.currentPlaylistPosition = position = this.playlistPagination.totalItems
145 } else {
146 return
147 }
148 }
149 const previous = this.playlistElements.find(e => e.position === position)
150
151 if (!previous || !previous.video) {
152 return this.findPreviousPlaylistVideo(position - 1)
153 }
154
155 return previous
156 }
157
158 navigateToPreviousPlaylistVideo () {
159 const previous = this.findPreviousPlaylistVideo(this.currentPlaylistPosition - 1)
160 if (!previous) return
161
162 const start = previous.startTimestamp
163 const stop = previous.stopTimestamp
164 this.router.navigate([],{ queryParams: { playlistPosition: previous.position, start, stop } })
165 }
166
140 findNextPlaylistVideo (position = this.currentPlaylistPosition): VideoPlaylistElement { 167 findNextPlaylistVideo (position = this.currentPlaylistPosition): VideoPlaylistElement {
141 if (this.currentPlaylistPosition >= this.playlistPagination.totalItems) { 168 if (this.currentPlaylistPosition >= this.playlistPagination.totalItems) {
142 // we have reached the end of the playlist: either loop or stop 169 // we have reached the end of the playlist: either loop or stop
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 366e9bb57..1f24c898e 100644
--- a/client/src/app/+videos/+video-watch/video-watch.component.ts
+++ b/client/src/app/+videos/+video-watch/video-watch.component.ts
@@ -799,6 +799,10 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
799 common: { 799 common: {
800 autoplay: this.isAutoplay(), 800 autoplay: this.isAutoplay(),
801 nextVideo: () => this.zone.run(() => this.autoplayNext()), 801 nextVideo: () => this.zone.run(() => this.autoplayNext()),
802 previousVideo: () => this.zone.run(() => {
803 // FIXME: Only show if this is a playlist
804 if (this.playlist) this.zone.run(() => this.videoWatchPlaylist.navigateToPreviousPlaylistVideo())
805 }),
802 806
803 playerElement: this.playerElement, 807 playerElement: this.playerElement,
804 onPlayerElementChange: (element: HTMLVideoElement) => this.playerElement = element, 808 onPlayerElementChange: (element: HTMLVideoElement) => this.playerElement = element,