From 275b6a0c12c09db12f11a528a4f89c175f5e2ffb Mon Sep 17 00:00:00 2001
From: Preston
Date: Wed, 3 Jun 2020 21:33:47 -0400
Subject: [PATCH] Add Next and Previous buttons to playlist in watch page
---
.../watch-video-playlist.js | 37 +++++++++++++++++++
.../watch-video-playlist.vue | 10 +++++
2 files changed, 47 insertions(+)
diff --git a/src/renderer/components/watch-video-playlist/watch-video-playlist.js b/src/renderer/components/watch-video-playlist/watch-video-playlist.js
index 46e1511a..12a100c0 100644
--- a/src/renderer/components/watch-video-playlist/watch-video-playlist.js
+++ b/src/renderer/components/watch-video-playlist/watch-video-playlist.js
@@ -177,6 +177,43 @@ export default Vue.extend({
}
},
+ playPreviousVideo: function () {
+ const playlistInfo = {
+ playlistId: this.playlistId
+ }
+
+ const watchedIndex = this.playlistItems.findIndex((watchedVideo) => {
+ return watchedVideo.videoId === this.videoId
+ })
+
+ if (this.shuffleEnabled && this.playlistWatchedVideoList.length > 1) {
+ this.playlistWatchedVideoList.pop()
+ const lastVideo = this.playlistWatchedVideoList.pop()
+ this.$router.push(
+ {
+ path: `/watch/${lastVideo}`,
+ query: playlistInfo
+ }
+ )
+ } else if (watchedIndex === 0) {
+ const videoId = this.playlistItems[this.playlistItems.length - 1].videoId
+ this.$router.push(
+ {
+ path: `/watch/${videoId}`,
+ query: playlistInfo
+ }
+ )
+ } else {
+ const videoId = this.playlistItems[watchedIndex - 1].videoId
+ this.$router.push(
+ {
+ path: `/watch/${videoId}`,
+ query: playlistInfo
+ }
+ )
+ }
+ },
+
getPlaylistInformationLocal: function () {
this.isLoading = true
diff --git a/src/renderer/components/watch-video-playlist/watch-video-playlist.vue b/src/renderer/components/watch-video-playlist/watch-video-playlist.vue
index d2025419..fdff39a8 100644
--- a/src/renderer/components/watch-video-playlist/watch-video-playlist.vue
+++ b/src/renderer/components/watch-video-playlist/watch-video-playlist.vue
@@ -36,6 +36,16 @@
icon="random"
@click="toggleShuffle"
/>
+
+