Implement persistence for caption settings (#1269)

This commit is contained in:
Seb 2021-06-10 15:35:00 -04:00 committed by GitHub
parent bd063a9d51
commit 2297bf3732
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -147,6 +147,15 @@ export default Vue.extend({
return parseInt(this.$store.getters.getDefaultQuality) return parseInt(this.$store.getters.getDefaultQuality)
}, },
defaultCaptionSettings: function () {
try {
return JSON.parse(this.$store.getters.getDefaultCaptionSettings)
} catch (e) {
console.log(e)
return {}
}
},
defaultVideoFormat: function () { defaultVideoFormat: function () {
return this.$store.getters.getDefaultVideoFormat return this.$store.getters.getDefaultVideoFormat
}, },
@ -225,6 +234,7 @@ export default Vue.extend({
this.player.volume(this.volume) this.player.volume(this.volume)
this.player.playbackRate(this.defaultPlayback) this.player.playbackRate(this.defaultPlayback)
this.player.textTrackSettings.setValues(this.defaultCaptionSettings)
// Remove big play button // Remove big play button
// https://github.com/videojs/video.js/blob/v7.12.1/docs/guides/components.md#basic-example // https://github.com/videojs/video.js/blob/v7.12.1/docs/guides/components.md#basic-example
if (!this.displayVideoPlayButton) { if (!this.displayVideoPlayButton) {
@ -304,6 +314,11 @@ export default Vue.extend({
this.powerSaveBlocker = null 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([ ...mapActions([
'showToast',
'calculateColorLuminance', 'calculateColorLuminance',
'updateDefaultCaptionSettings',
'showToast',
'sponsorBlockSkipSegments' 'sponsorBlockSkipSegments'
]) ])
} }

View File

@ -81,6 +81,7 @@ const state = {
defaultPlayback: 1, defaultPlayback: 1,
defaultVideoFormat: 'dash', defaultVideoFormat: 'dash',
defaultQuality: '720', defaultQuality: '720',
defaultCaptionSettings: '{}',
useProxy: false, useProxy: false,
proxyProtocol: 'socks5', proxyProtocol: 'socks5',
proxyHostname: '127.0.0.1', proxyHostname: '127.0.0.1',