--- /dev/null
+function getStoredVolume () {
+ const value = getLocalStorage('volume')
+ if (value !== null && value !== undefined) {
+ const valueNumber = parseFloat(value)
+ if (isNaN(valueNumber)) return undefined
+
+ return valueNumber
+ }
+
+ return undefined
+}
+
+function getStoredMute () {
+ const value = getLocalStorage('mute')
+ if (value !== null && value !== undefined) return value === 'true'
+
+ return undefined
+}
+
+function getStoredTheater () {
+ const value = getLocalStorage('theater-enabled')
+ if (value !== null && value !== undefined) return value === 'true'
+
+ return undefined
+}
+
+function saveVolumeInStore (value: number) {
+ return setLocalStorage('volume', value.toString())
+}
+
+function saveMuteInStore (value: boolean) {
+ return setLocalStorage('mute', value.toString())
+}
+
+function saveTheaterInStore (enabled: boolean) {
+ return setLocalStorage('theater-enabled', enabled.toString())
+}
+
+function saveAverageBandwidth (value: number) {
+ return setLocalStorage('average-bandwidth', value.toString())
+}
+
+function getAverageBandwidthInStore () {
+ const value = getLocalStorage('average-bandwidth')
+ if (value !== null && value !== undefined) {
+ const valueNumber = parseInt(value, 10)
+ if (isNaN(valueNumber)) return undefined
+
+ return valueNumber
+ }
+
+ return undefined
+}
+
+
+// ---------------------------------------------------------------------------
+
+export {
+ getStoredVolume,
+ getStoredMute,
+ getStoredTheater,
+ saveVolumeInStore,
+ saveMuteInStore,
+ saveTheaterInStore,
+ saveAverageBandwidth,
+ getAverageBandwidthInStore
+}
+
+// ---------------------------------------------------------------------------
+
+const KEY_PREFIX = 'peertube-videojs-'
+
+function getLocalStorage (key: string) {
+ try {
+ return localStorage.getItem(KEY_PREFIX + key)
+ } catch {
+ return undefined
+ }
+}
+
+function setLocalStorage (key: string, value: string) {
+ try {
+ localStorage.setItem(KEY_PREFIX + key, value)
+ } catch { /* empty */
+ }
+}
import { renderVideo } from './video-renderer'
import './settings-menu-button'
import { PeertubePluginOptions, VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings'
+import { isMobile, videoFileMaxByResolution, videoFileMinByResolution } from './utils'
+import * as CacheChunkStore from 'cache-chunk-store'
+import { PeertubeChunkStore } from './peertube-chunk-store'
import {
- getAverageBandwidth,
+ getAverageBandwidthInStore,
getStoredMute,
- getStoredVolume, isMobile,
+ getStoredVolume,
saveAverageBandwidth,
saveMuteInStore,
- saveVolumeInStore,
- videoFileMaxByResolution,
- videoFileMinByResolution
-} from './utils'
-import * as CacheChunkStore from 'cache-chunk-store'
-import { PeertubeChunkStore } from './peertube-chunk-store'
+ saveVolumeInStore
+} from './peertube-player-local-storage'
const Plugin: VideoJSComponentInterface = videojs.getPlugin('plugin')
class PeerTubePlugin extends Plugin {
) {
// Automatically choose the adapted video file
if (videoFile === undefined) {
- const savedAverageBandwidth = getAverageBandwidth()
+ const savedAverageBandwidth = getAverageBandwidthInStore()
videoFile = savedAverageBandwidth
? this.getAppropriateFile(savedAverageBandwidth)
: this.pickAverageVideoFile()
import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings'
-import { getStoredTheater, saveTheaterInStore } from './utils'
+import { saveTheaterInStore } from './peertube-player-local-storage'
+import { getStoredTheater } from './peertube-player-local-storage'
const Button: VideoJSComponentInterface = videojsUntyped.getComponent('Button')
class TheaterButton extends Button {
-import { is18nLocale, isDefaultLocale } from '../../../../shared/models/i18n/i18n'
import { VideoFile } from '../../../../shared/models/videos'
function toTitleCase (str: string) {
return [ calc, format.type ]
}
-function getStoredVolume () {
- const value = getLocalStorage('volume')
- if (value !== null && value !== undefined) {
- const valueNumber = parseFloat(value)
- if (isNaN(valueNumber)) return undefined
-
- return valueNumber
- }
-
- return undefined
-}
-
-function getStoredMute () {
- const value = getLocalStorage('mute')
- if (value !== null && value !== undefined) return value === 'true'
-
- return undefined
-}
-
-function getAverageBandwidth () {
- const value = getLocalStorage('average-bandwidth')
- if (value !== null && value !== undefined) {
- const valueNumber = parseInt(value, 10)
- if (isNaN(valueNumber)) return undefined
-
- return valueNumber
- }
-
- return undefined
-}
-
-function getStoredTheater () {
- const value = getLocalStorage('theater-enabled')
- if (value !== null && value !== undefined) return value === 'true'
-
- return undefined
-}
-
-function saveVolumeInStore (value: number) {
- return setLocalStorage('volume', value.toString())
-}
-
-function saveMuteInStore (value: boolean) {
- return setLocalStorage('mute', value.toString())
-}
-
-function saveTheaterInStore (enabled: boolean) {
- return setLocalStorage('theater-enabled', enabled.toString())
-}
-
-function saveAverageBandwidth (value: number) {
- return setLocalStorage('average-bandwidth', value.toString())
-}
-
function isMobile () {
return /iPhone|iPad|iPod|Android/i.test(navigator.userAgent)
}
return min
}
+// ---------------------------------------------------------------------------
+
export {
toTitleCase,
buildVideoLink,
- getStoredVolume,
- saveVolumeInStore,
- saveAverageBandwidth,
- getAverageBandwidth,
- saveMuteInStore,
buildVideoEmbed,
- getStoredMute,
videoFileMaxByResolution,
videoFileMinByResolution,
copyToClipboard,
- getStoredTheater,
- saveTheaterInStore,
isMobile,
bytes
}
-
-// ---------------------------------------------------------------------------
-
-const KEY_PREFIX = 'peertube-videojs-'
-
-function getLocalStorage (key: string) {
- try {
- return localStorage.getItem(KEY_PREFIX + key)
- } catch {
- return undefined
- }
-}
-
-function setLocalStorage (key: string, value: string) {
- try {
- localStorage.setItem(KEY_PREFIX + key, value)
- } catch { /* empty */ }
-}