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) }, }, })