From e439730a4d3d1c26b5b1e2e3098188c08fd04a60 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Fri, 8 Nov 2024 23:49:43 +0100 Subject: [PATCH] feat: :sparkles: Playback speed and volume setting doesn't stick (fix #185) --- src/store/player.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/store/player.ts b/src/store/player.ts index 617d575..f4872c6 100644 --- a/src/store/player.ts +++ b/src/store/player.ts @@ -1,4 +1,5 @@ import type { EpisodeActionInterface, EpisodeInterface } from '../utils/types.ts' +import { getCookie, setCookie } from '../utils/cookies.ts' import axios from '@nextcloud/axios' import { defineStore } from 'pinia' import { formatEpisodeTimestamp } from '../utils/time.ts' @@ -23,6 +24,9 @@ export const usePlayer = defineStore('player', { }), actions: { init() { + audio.playbackRate = parseFloat(getCookie('repod.rate') || '1') + audio.volume = parseFloat(getCookie('repod.volume') || '1') + audio.ondurationchange = () => (this.duration = audio.duration) audio.onended = () => this.stop() audio.onloadeddata = () => (this.loaded = true) @@ -123,9 +127,11 @@ export const usePlayer = defineStore('player', { }, setVolume(volume: number) { audio.volume = volume + setCookie('repod.volume', volume.toString(), 365) }, setRate(rate: number) { audio.playbackRate = rate + setCookie('repod.rate', rate.toString(), 365) }, }, })