-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b0c499a
commit c5bf988
Showing
11 changed files
with
305 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Code, Grid, Group, Paper, Stack, Text } from "@mantine/core"; | ||
import { VideoFormat } from "../../api/types/format"; | ||
import { IconCheck } from "@tabler/icons-react"; | ||
|
||
export const FormatCard = ({ | ||
format, | ||
isSelected, | ||
onClick, | ||
}: { | ||
format: VideoFormat, | ||
isSelected?: boolean, | ||
onClick?: () => void, | ||
}) => { | ||
return ( | ||
<Paper w="100%" withBorder p="xs" bg={isSelected ? "dark.6" : undefined} style={{ | ||
cursor: "pointer", | ||
}} onClick={onClick}> | ||
<Grid> | ||
<Grid.Col span="content"> | ||
<Stack h="100%" justify="center" align="center"> | ||
{isSelected && ( | ||
<IconCheck color="var(--mantine-color-green-filled)" /> | ||
)} | ||
</Stack> | ||
</Grid.Col> | ||
<Grid.Col span="auto"> | ||
<Stack align="start" gap={0}> | ||
<Group w="100%" justify="space-between"> | ||
<Code> | ||
{format.id} | ||
</Code> | ||
<Code> | ||
{format.itag} | ||
</Code> | ||
</Group> | ||
<Text> | ||
{format.mimeType} | ||
</Text> | ||
</Stack> | ||
</Grid.Col> | ||
</Grid> | ||
</Paper> | ||
); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,32 @@ | ||
import { Group, Select, Stack } from "@mantine/core"; | ||
import { Grid, Select, Stack, Text, UnstyledButton } from "@mantine/core"; | ||
import { useContext } from "react"; | ||
import { VideoPlayerContext } from "../../../api/context/VideoPlayerContext"; | ||
import { IconCheck } from "@tabler/icons-react"; | ||
import { FormatCard } from "../../cards/FormatCard"; | ||
import { OptionsContext } from "../OptionsContext"; | ||
import { IconArrowRight } from "@tabler/icons-react"; | ||
|
||
export const FormatSelect = () => { | ||
const { | ||
availableFormats, | ||
activeFormat, | ||
setFormat, | ||
} = useContext(VideoPlayerContext); | ||
const { setView } = useContext(OptionsContext); | ||
const { activeFormat } = useContext(VideoPlayerContext); | ||
|
||
return ( | ||
<Select | ||
w="100%" | ||
label={"Format"} | ||
value={activeFormat.itag} | ||
onChange={(v) => setFormat(v)} | ||
data={availableFormats.map((f, i) => f.id)} | ||
renderOption={({ option: { value }, checked }) => ( | ||
<Group justify="space-between"> | ||
<Group> | ||
<Stack> | ||
{availableFormats.find(x => x.id == value).id} | ||
{availableFormats.find(x => x.id == value).itag} | ||
{availableFormats.find(x => x.id == value).mimeType} | ||
{availableFormats.find(x => x.id == value).fps} | ||
</Stack> | ||
</Group> | ||
<Group> | ||
{checked && <IconCheck />} | ||
</Group> | ||
</Group> | ||
)} | ||
/> | ||
<Stack w="100%" gap={0}> | ||
<Text> | ||
Selected Format | ||
</Text> | ||
<UnstyledButton | ||
className="hoverable" | ||
variant="subtle" | ||
color="violet" | ||
onClick={() => setView("formatSelect")} | ||
> | ||
{activeFormat ? ( | ||
<FormatCard | ||
format={activeFormat} | ||
isSelected | ||
/> | ||
) : "Loading..."} | ||
</UnstyledButton> | ||
</Stack> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { useContext, useState } from "react"; | ||
import { OptionsContext } from "../OptionsContext"; | ||
import { Button, Checkbox, Group, SegmentedControl, Stack, Text } from "@mantine/core"; | ||
import { IconArrowLeft } from "@tabler/icons-react"; | ||
import { VideoPlayerContext } from "../../../api/context/VideoPlayerContext"; | ||
import { FormatCard } from "../../cards/FormatCard"; | ||
import { VideoFormatType } from "../../../api/types/format"; | ||
|
||
export const OptionsFormatView = () => { | ||
const { setView } = useContext(OptionsContext); | ||
const { | ||
availableFormats, | ||
activeFormat, | ||
setFormat, | ||
} = useContext(VideoPlayerContext); | ||
|
||
const [filterFormatType, setFilterFormatType] = useState<VideoFormatType | "all">("basic"); | ||
const [filterProxy, setFilterProxy] = useState<boolean | null>(null); | ||
|
||
const options = availableFormats | ||
.filter(f => filterFormatType == "all" || f.type == filterFormatType) | ||
.filter(f => filterProxy === null || f.isProxied == filterProxy); | ||
|
||
return ( | ||
<Stack w="100%"> | ||
<Stack w="100%"> | ||
<Group w="100%" justify="space-between"> | ||
<Text> | ||
Format Types | ||
</Text> | ||
<SegmentedControl | ||
data={[ | ||
"all", | ||
"basic", | ||
"adaptive", | ||
"dash", | ||
"hls", | ||
]} | ||
value={filterFormatType} | ||
onChange={(v) => setFilterFormatType(v as VideoFormatType | "all")} | ||
/> | ||
</Group> | ||
<Group w="100%" justify="space-between"> | ||
<Text> | ||
Proxied | ||
</Text> | ||
<SegmentedControl | ||
data={[ | ||
"all", | ||
"true", | ||
"false", | ||
]} | ||
value={filterProxy === null ? "all" : String(filterProxy)} | ||
onChange={(v) => setFilterProxy(v == "all" ? null : (v == "true" ? true : false))} | ||
/> | ||
</Group> | ||
</Stack> | ||
<Stack w="100%"> | ||
{options.map((format, i) => ( | ||
<FormatCard | ||
format={format} | ||
isSelected={activeFormat.id == format.id} | ||
onClick={() => setFormat(format.id)} | ||
key={i} | ||
/> | ||
))} | ||
</Stack> | ||
</Stack> | ||
); | ||
}; |
Oops, something went wrong.