1 function getStoredVolume () {
2 const value = getLocalStorage('volume')
3 if (value !== null && value !== undefined) {
4 const valueNumber = parseFloat(value)
5 if (isNaN(valueNumber)) return undefined
13 function getStoredP2PEnabled (): boolean {
14 const value = getLocalStorage('webtorrent_enabled')
15 if (value !== null && value !== undefined) return value === 'true'
17 // By default webtorrent is enabled
21 function getStoredMute () {
22 const value = getLocalStorage('mute')
23 if (value !== null && value !== undefined) return value === 'true'
28 function getStoredTheater () {
29 const value = getLocalStorage('theater-enabled')
30 if (value !== null && value !== undefined) return value === 'true'
35 function saveVolumeInStore (value: number) {
36 return setLocalStorage('volume', value.toString())
39 function saveMuteInStore (value: boolean) {
40 return setLocalStorage('mute', value.toString())
43 function saveTheaterInStore (enabled: boolean) {
44 return setLocalStorage('theater-enabled', enabled.toString())
47 function saveAverageBandwidth (value: number) {
48 return setLocalStorage('average-bandwidth', value.toString())
51 function getAverageBandwidthInStore () {
52 const value = getLocalStorage('average-bandwidth')
53 if (value !== null && value !== undefined) {
54 const valueNumber = parseInt(value, 10)
55 if (isNaN(valueNumber)) return undefined
63 function saveLastSubtitle (language: string) {
64 return setLocalStorage('last-subtitle', language)
67 function getStoredLastSubtitle () {
68 return getLocalStorage('last-subtitle')
71 // ---------------------------------------------------------------------------
82 getAverageBandwidthInStore,
87 // ---------------------------------------------------------------------------
89 const KEY_PREFIX = 'peertube-videojs-'
91 function getLocalStorage (key: string) {
93 return localStorage.getItem(KEY_PREFIX + key)
99 function setLocalStorage (key: string, value: string) {
101 localStorage.setItem(KEY_PREFIX + key, value)
102 } catch { /* empty */