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:
parent
b405090f54
commit
90f9947493
1 changed files with 12 additions and 5 deletions
|
@ -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
|
||||
})
|
||||
}
|
Loading…
Reference in a new issue