From 3b75a978594d2ac5c5ac888b07c7f984928d2c79 Mon Sep 17 00:00:00 2001 From: Sai Deepesh Date: Sat, 6 Mar 2021 21:55:50 +0530 Subject: [PATCH] added playlist next video interval (#1006) --- .../player-settings/player-settings.js | 5 +++++ .../player-settings/player-settings.vue | 9 +++++++++ src/renderer/store/modules/settings.js | 19 +++++++++++++++++++ src/renderer/views/Watch/Watch.js | 10 +++++++--- static/locales/en-US.yaml | 4 ++-- 5 files changed, 42 insertions(+), 5 deletions(-) diff --git a/src/renderer/components/player-settings/player-settings.js b/src/renderer/components/player-settings/player-settings.js index 73d50332..49a74d0d 100644 --- a/src/renderer/components/player-settings/player-settings.js +++ b/src/renderer/components/player-settings/player-settings.js @@ -62,6 +62,10 @@ export default Vue.extend({ return this.$store.getters.getProxyVideos }, + defaultInterval: function () { + return parseInt(this.$store.getters.getDefaultInterval) + }, + defaultVolume: function () { return parseFloat(this.$store.getters.getDefaultVolume) * 100 }, @@ -119,6 +123,7 @@ export default Vue.extend({ 'updateForceLocalBackendForLegacy', 'updateProxyVideos', 'updateDefaultTheatreMode', + 'updateDefaultInterval', 'updateDefaultVolume', 'updateDefaultPlayback', 'updateDefaultVideoFormat', diff --git a/src/renderer/components/player-settings/player-settings.vue b/src/renderer/components/player-settings/player-settings.vue index 8b7ff1ec..001b9486 100644 --- a/src/renderer/components/player-settings/player-settings.vue +++ b/src/renderer/components/player-settings/player-settings.vue @@ -61,6 +61,15 @@ + { + return state.defaultInterval + }, + getDefaultVolume: () => { return state.defaultVolume }, @@ -356,6 +361,9 @@ const actions = { case 'defaultTheatreMode': commit('setDefaultTheatreMode', result.value) break + case 'defaultInterval': + commit('setDefaultInterval', result.value) + break case 'defaultVolume': commit('setDefaultVolume', result.value) sessionStorage.setItem('volume', result.value) @@ -598,6 +606,14 @@ const actions = { }) }, + updateDefaultInterval ({ commit }, defaultInterval) { + settingsDb.update({ _id: 'defaultInterval' }, { _id: 'defaultInterval', value: defaultInterval }, { upsert: true }, (err, numReplaced) => { + if (!err) { + commit('setDefaultInterval', defaultInterval) + } + }) + }, + updateDefaultVolume ({ commit }, defaultVolume) { settingsDb.update({ _id: 'defaultVolume' }, { _id: 'defaultVolume', value: defaultVolume }, { upsert: true }, (err, numReplaced) => { if (!err) { @@ -819,6 +835,9 @@ const mutations = { setProxyVideos (state, proxyVideos) { state.proxyVideos = proxyVideos }, + setDefaultInterval (state, defaultInterval) { + state.defaultInterval = defaultInterval + }, setDefaultVolume (state, defaultVolume) { state.defaultVolume = defaultVolume }, diff --git a/src/renderer/views/Watch/Watch.js b/src/renderer/views/Watch/Watch.js index 37d6fdf5..bcc7b34a 100644 --- a/src/renderer/views/Watch/Watch.js +++ b/src/renderer/views/Watch/Watch.js @@ -105,6 +105,9 @@ export default Vue.extend({ proxyVideos: function () { return this.$store.getters.getProxyVideos }, + defaultInterval: function () { + return this.$store.getters.getDefaultInterval + }, defaultTheatreMode: function () { return this.$store.getters.getDefaultTheatreMode }, @@ -808,14 +811,15 @@ export default Vue.extend({ }, handleVideoEnded: function () { + const nextVideoInterval = this.defaultInterval if (this.watchingPlaylist) { this.playNextTimeout = setTimeout(() => { this.$refs.watchVideoPlaylist.playNextVideo() - }, 5000) + }, nextVideoInterval * 1000) this.showToast({ - message: this.$t('Playing next video in 5 seconds. Click to cancel'), - time: 5500, + message: this.$tc('Playing Next Video Interval', nextVideoInterval, { nextVideoInterval: nextVideoInterval }), + time: (nextVideoInterval * 1000) + 500, action: () => { clearTimeout(this.playNextTimeout) this.showToast({ diff --git a/static/locales/en-US.yaml b/static/locales/en-US.yaml index 951972ee..2870b097 100644 --- a/static/locales/en-US.yaml +++ b/static/locales/en-US.yaml @@ -171,6 +171,7 @@ Settings: Proxy Videos Through Invidious: Proxy Videos Through Invidious Autoplay Playlists: Autoplay Playlists Enable Theatre Mode by Default: Enable Theatre Mode by Default + Playlist Next Video Interval: Playlist Next Video Interval Default Volume: Default Volume Default Playback Rate: Default Playback Rate Default Video Format: @@ -586,8 +587,7 @@ Shuffle is now enabled: Shuffle is now enabled The playlist has been reversed: The playlist has been reversed Playing Next Video: Playing Next Video Playing Previous Video: Playing Previous Video -Playing next video in 5 seconds. Click to cancel: Playing next video in 5 seconds. - Click to cancel. +Playing Next Video Interval: Playing next video in no time. Click to cancel. | Playing next video in {nextVideoInterval} second. Click to cancel. | Playing next video in {nextVideoInterval} seconds. Click to cancel. Canceled next video autoplay: Canceled next video autoplay 'The playlist has ended. Enable loop to continue playing': 'The playlist has ended. Enable loop to continue playing'