From 2297bf3732a12fffccb0eabc6c67d8033e637a5d Mon Sep 17 00:00:00 2001 From: Seb Date: Thu, 10 Jun 2021 15:35:00 -0400 Subject: [PATCH] Implement persistence for caption settings (#1269) --- .../ft-video-player/ft-video-player.js | 18 +++++++++++++++++- src/renderer/store/modules/settings.js | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/renderer/components/ft-video-player/ft-video-player.js b/src/renderer/components/ft-video-player/ft-video-player.js index 9b692e3e..896cbd5a 100644 --- a/src/renderer/components/ft-video-player/ft-video-player.js +++ b/src/renderer/components/ft-video-player/ft-video-player.js @@ -147,6 +147,15 @@ export default Vue.extend({ return parseInt(this.$store.getters.getDefaultQuality) }, + defaultCaptionSettings: function () { + try { + return JSON.parse(this.$store.getters.getDefaultCaptionSettings) + } catch (e) { + console.log(e) + return {} + } + }, + defaultVideoFormat: function () { return this.$store.getters.getDefaultVideoFormat }, @@ -225,6 +234,7 @@ export default Vue.extend({ this.player.volume(this.volume) this.player.playbackRate(this.defaultPlayback) + this.player.textTrackSettings.setValues(this.defaultCaptionSettings) // Remove big play button // https://github.com/videojs/video.js/blob/v7.12.1/docs/guides/components.md#basic-example if (!this.displayVideoPlayButton) { @@ -304,6 +314,11 @@ export default Vue.extend({ this.powerSaveBlocker = null } }) + + this.player.textTrackSettings.on('modalclose', (_) => { + const settings = this.player.textTrackSettings.getValues() + this.updateDefaultCaptionSettings(JSON.stringify(settings)) + }) } }, @@ -1357,8 +1372,9 @@ export default Vue.extend({ }, ...mapActions([ - 'showToast', 'calculateColorLuminance', + 'updateDefaultCaptionSettings', + 'showToast', 'sponsorBlockSkipSegments' ]) } diff --git a/src/renderer/store/modules/settings.js b/src/renderer/store/modules/settings.js index f7e15a85..1d2e1b31 100644 --- a/src/renderer/store/modules/settings.js +++ b/src/renderer/store/modules/settings.js @@ -81,6 +81,7 @@ const state = { defaultPlayback: 1, defaultVideoFormat: 'dash', defaultQuality: '720', + defaultCaptionSettings: '{}', useProxy: false, proxyProtocol: 'socks5', proxyHostname: '127.0.0.1',