mirror of
https://codeberg.org/SafeTwitch/safetwitch.git
synced 2024-12-22 13:22:58 -05:00
Improve quality
This commit is contained in:
parent
93ca3a612a
commit
fc498f078d
3 changed files with 40 additions and 24 deletions
|
@ -4,6 +4,7 @@ import videojs from 'video.js'
|
|||
import 'videojs-contrib-quality-levels'
|
||||
import type { QualityLevelList, QualityLevel } from 'videojs-contrib-quality-levels'
|
||||
import i18n from '@/i18n'
|
||||
import { getSetting } from '@/mixins'
|
||||
|
||||
const getQualityFromSettings = (qualityLevels) => {
|
||||
const settings = localStorage.getItem("settings")
|
||||
|
@ -52,7 +53,7 @@ export const createQualitySelector = (player: any) => {
|
|||
}
|
||||
|
||||
// set quality on startup
|
||||
const startingQuality = getQualityFromSettings()
|
||||
const startingQuality = getSetting("defaultQuality")
|
||||
const id = formatedQualities.find((i) => i.name === startingQuality)?.id
|
||||
setQuality(id)
|
||||
|
||||
|
|
|
@ -41,13 +41,43 @@ export async function getEndpoint(endpoint: string) {
|
|||
return data
|
||||
}
|
||||
|
||||
export function chatVisible() {
|
||||
const storage = localStorage.getItem('settings')
|
||||
if (!storage) return true
|
||||
const parsed = JSON.parse(storage)
|
||||
export function getDefaultSettings() {
|
||||
return {
|
||||
"audioOnly": {
|
||||
"name": "Audio Only",
|
||||
"selected": false,
|
||||
"type": "checkbox"
|
||||
},
|
||||
"defaultQuality": {
|
||||
"name": "Default Quality",
|
||||
"options": ["160p", "360p", "480p", "720p", "1080p"],
|
||||
"selected": "480p",
|
||||
"type": "option"
|
||||
},
|
||||
"chatVisible": {
|
||||
"name": "Hide Chat",
|
||||
"selected": false,
|
||||
"type": "checkbox"
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export function getSetting(key: string): boolean | string {
|
||||
const storage = localStorage.getItem('settings')
|
||||
let parsed
|
||||
if (!storage) {
|
||||
parsed = getDefaultSettings()
|
||||
} else {
|
||||
parsed = JSON.parse(storage)
|
||||
}
|
||||
|
||||
return parsed[key].selected
|
||||
}
|
||||
|
||||
export function chatVisible() {
|
||||
const p = getSetting("chatVisible")
|
||||
// Flip becuase on the setting page it's
|
||||
// displayed as "Hide Chat", but the value
|
||||
// is chatVisible
|
||||
return !parsed.chatVisible.selected
|
||||
return !p
|
||||
}
|
||||
|
|
|
@ -1,28 +1,13 @@
|
|||
<script lang="ts">
|
||||
import { getDefaultSettings } from '@/mixins'
|
||||
|
||||
export default {
|
||||
setup() {
|
||||
let settings
|
||||
|
||||
let storedSettings = localStorage.getItem("settings")
|
||||
if (storedSettings === null) {
|
||||
settings = {
|
||||
"audioOnly": {
|
||||
"name": "Audio Only",
|
||||
"selected": false,
|
||||
"type": "checkbox"
|
||||
},
|
||||
"defaultQuality": {
|
||||
"name": "Default Quality",
|
||||
"options": ["160p", "360p", "480p", "720p", "1080p"],
|
||||
"selected": "480p",
|
||||
"type": "option"
|
||||
},
|
||||
"chatVisible": {
|
||||
"name": "Hide Chat",
|
||||
"selected": false,
|
||||
"type": "checkbox"
|
||||
},
|
||||
}
|
||||
settings = getDefaultSettings()
|
||||
} else {
|
||||
settings = JSON.parse(storedSettings)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue