diff --git a/src/assets/qualitySelector.ts b/src/assets/qualitySelector.ts index 009ed5a..984e3b6 100644 --- a/src/assets/qualitySelector.ts +++ b/src/assets/qualitySelector.ts @@ -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 - }) -} +} \ No newline at end of file