diff --git a/package.json b/package.json index 5a880018..f3f7b5e2 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "core-js": "^3.29.1", "crypto-js": "^4.1.1", "dompurify": "^3.0.1", + "flag-icons": "^6.11.1", "fscreen": "^1.2.0", "fuse.js": "^6.4.6", "hls.js": "^1.0.7", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 43a2da12..694d52bd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -38,6 +38,9 @@ dependencies: dompurify: specifier: ^3.0.1 version: 3.0.5 + flag-icons: + specifier: ^6.11.1 + version: 6.11.1 fscreen: specifier: ^1.2.0 version: 1.2.0 @@ -3770,6 +3773,10 @@ packages: path-exists: 4.0.0 dev: true + /flag-icons@6.11.1: + resolution: {integrity: sha512-c2UMJTFZoVQ47/sE1mb+9b5S1pi8SjXsx0MR063O31GV+O2EN4FMwMdEYSQItpien2bl9w1viLUoo2R3r6OK3g==} + dev: false + /flat-cache@3.1.0: resolution: {integrity: sha512-OHx4Qwrrt0E4jEIcI5/Xb+f+QmJYNj2rrK8wiIdQOIrB9WrrJL8cjZvXdXuBTkkEwEqLycb5BeZDV1o2i9bTew==} engines: {node: '>=12.0.0'} diff --git a/src/components/player/atoms/Settings.tsx b/src/components/player/atoms/Settings.tsx index e2ca4a9c..9b0f7173 100644 --- a/src/components/player/atoms/Settings.tsx +++ b/src/components/player/atoms/Settings.tsx @@ -1,3 +1,5 @@ +import "flag-icons/css/flag-icons.min.css"; + import classNames from "classnames"; import { useCallback, useEffect, useState } from "react"; @@ -141,15 +143,61 @@ function CaptionSettingsView({ id }: { id: string }) { ); } +function CaptionOption(props: { + countryCode?: string; + children: React.ReactNode; + selected?: boolean; +}) { + return ( +
+
+ +
+ + {props.children} + + {props.selected ? ( + + ) : null} +
+ ); +} + function CaptionsView({ id }: { id: string }) { const router = useOverlayRouter(id); return ( <> - router.navigate("/captions")}> + router.navigate("/")} + rightSide={ + + } + > Captions - Yee! + + Off + + Nederlands + + Idk Gibraltar of zo? + ); } diff --git a/src/stores/player/utils/qualities.ts b/src/stores/player/utils/qualities.ts index 2def1113..b83ef303 100644 --- a/src/stores/player/utils/qualities.ts +++ b/src/stores/player/utils/qualities.ts @@ -22,6 +22,17 @@ export type SourceSliceSource = url: string; }; +const qualitySorting: Record = { + "1080": 40, + "360": 10, + "480": 20, + "720": 30, + unknown: 0, +}; +const sortedQualities: SourceQuality[] = Object.entries(qualitySorting) + .sort((a, b) => b[1] - a[1]) + .map((v) => v[0] as SourceQuality); + export function selectQuality(source: SourceSliceSource): { stream: LoadableSource; quality: null | SourceQuality; @@ -32,12 +43,14 @@ export function selectQuality(source: SourceSliceSource): { quality: null, }; if (source.type === "file") { - const firstQuality = Object.keys( - source.qualities - )[0] as keyof typeof source.qualities; - const stream = source.qualities[firstQuality]; - if (stream) { - return { stream, quality: firstQuality }; + const bestQuality = sortedQualities.find( + (v) => source.qualities[v] && (source.qualities[v]?.url.length ?? 0) > 0 + ); + if (bestQuality) { + const stream = source.qualities[bestQuality]; + if (stream) { + return { stream, quality: bestQuality }; + } } } throw new Error("couldn't select quality"); diff --git a/tailwind.config.js b/tailwind.config.js index 2dac6a03..b04e5b6a 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -136,6 +136,7 @@ module.exports = { light: "#4D79A8", border: "#4F5C66", buttonFocus: "#202836", + flagBg: "#202836", type: { main: "#617A8A",