0
Fork 0
mirror of https://codeberg.org/SafeTwitch/safetwitch.git synced 2024-12-22 13:22:58 -05:00

Set quality to default quality on load

This commit is contained in:
dragongoose 2023-08-16 13:34:04 -04:00
parent b405090f54
commit 90f9947493
No known key found for this signature in database
GPG key ID: 01397EEC371CDAA5

View file

@ -5,6 +5,12 @@ import 'videojs-contrib-quality-levels'
import type { QualityLevelList, QualityLevel } from 'videojs-contrib-quality-levels'
import i18n from '@/i18n'
const getQualityFromSettings = (qualityLevels) => {
const settings = localStorage.getItem("settings")
const parsed = JSON.parse(settings)
return parsed.defaultQuality.selected
}
export const createQualitySelector = (player: any) => {
const qualityLevels: QualityLevelList = player.qualityLevels()
const MenuButton = videojs.getComponent('MenuButton')
@ -45,6 +51,11 @@ export const createQualitySelector = (player: any) => {
}
}
// set quality on startup
const startingQuality = getQualityFromSettings()
const id = formatedQualities.find((i) => i.name === startingQuality)?.id
setQuality(id)
return qualitySelectorButton
})
}
@ -76,8 +87,4 @@ export const createQualitySelector = (player: any) => {
formattedLevels.push(formatedQualities)
updateLevels()
})
qualityLevels.on('change', function () {
// TODO: Change label off button
})
}
}