-
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
7acb4e4
commit 86f35ef
Showing
12 changed files
with
198 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { useContext } from "react"; | ||
import { TabsContext } from "../../tabs/TabsContext"; | ||
import { SegmentedControl } from "@mantine/core"; | ||
import { UIFlavor } from "../../tabs/TabTypes"; | ||
|
||
export const FlavorOption = () => { | ||
const { flavor, setFlavor } = useContext(TabsContext); | ||
|
||
return ( | ||
<SegmentedControl | ||
value={flavor} | ||
data={["video", "music"] as UIFlavor[]} | ||
onChange={(v) => setFlavor(v as UIFlavor)} | ||
/> | ||
) | ||
}; |
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,28 @@ | ||
import { ActionIcon, Tooltip } from "@mantine/core"; | ||
import { useFullscreen } from "@mantine/hooks"; | ||
import { IconMaximize, IconMinimize, IconRepeat, IconRepeatOff } from "@tabler/icons-react"; | ||
import { useContext, useState } from "react"; | ||
import { VideoPlayerContext } from "../../../api/player/VideoPlayerContext"; | ||
|
||
export const LoopButton = () => { | ||
const { videoElement } = useContext(VideoPlayerContext); | ||
const [loop, setLoop] = useState(videoElement.loop); | ||
|
||
return ( | ||
<Tooltip label={loop ? "Turn off loop" : "Click to turn on loop"}> | ||
<ActionIcon | ||
onClick={() => { | ||
videoElement.loop = !videoElement.loop; | ||
setLoop(!videoElement.loop); | ||
}} | ||
variant="light" | ||
> | ||
{loop ? ( | ||
<IconRepeatOff /> | ||
) : ( | ||
<IconRepeat /> | ||
)} | ||
</ActionIcon> | ||
</Tooltip> | ||
); | ||
}; |
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,28 @@ | ||
import { Group, Paper, Stack } from "@mantine/core" | ||
import { PlayPauseButton } from "../controls/PlayPauseButton" | ||
import { VolumeControls } from "../controls/VolumeControls" | ||
import { PlayerTimestamp } from "../controls/PlayerTimestamp" | ||
import { ProgressBar } from "../bar/ProgressBar" | ||
import { LoopButton } from "../controls/LoopButton" | ||
import { PlayerLayoutTop } from "../layout/LayoutTop" | ||
|
||
export const MusicControls = () => { | ||
return ( | ||
<Paper withBorder p="sm" bg="dark"> | ||
<Stack> | ||
<PlayerLayoutTop /> | ||
<ProgressBar /> | ||
<Group justify="space-between"> | ||
<Group> | ||
<PlayPauseButton /> | ||
<VolumeControls /> | ||
<PlayerTimestamp /> | ||
</Group> | ||
<Group> | ||
<LoopButton /> | ||
</Group> | ||
</Group> | ||
</Stack> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { useContext, useEffect, useRef, useState } from "react"; | ||
import { VideoPlayerContext } from "../../../api/player/VideoPlayerContext" | ||
import { Box, Stack, Transition } from "@mantine/core"; | ||
import { useDebouncedCallback, useHotkeys, useHover, useMergedRef } from "@mantine/hooks"; | ||
import { usePreference } from "../../../api/pref/Preferences"; | ||
import { MusicControls } from "./MusicControls"; | ||
import { useIsMobile } from "../../../hooks/useIsMobile"; | ||
|
||
export const MusicPlayer = () => { | ||
const { | ||
videoElement, | ||
seekToChapterOffset, | ||
seekTo, | ||
togglePlay, | ||
playState, | ||
muted, | ||
setMuted, | ||
autoplayDate, | ||
} = useContext(VideoPlayerContext); | ||
const videoContainerRef = useRef<HTMLDivElement>(null); | ||
|
||
useEffect(() => { | ||
videoContainerRef.current?.appendChild(videoElement); | ||
if(videoElement.paused && videoElement.currentSrc && videoElement.currentTime) | ||
videoElement.play(); | ||
return () => { | ||
videoElement.pause(); | ||
}; | ||
}, [videoElement, videoContainerRef.current]); | ||
|
||
useHotkeys([ | ||
["ArrowLeft", () => seekTo(videoElement.currentTime - 5)], | ||
["ArrowRight", () => seekTo(videoElement.currentTime + 5)], | ||
["Shift + ArrowRight", () => seekToChapterOffset(1)], | ||
["Shift + ArrowLeft", () => seekToChapterOffset(-1)], | ||
["J", () => seekTo(videoElement.currentTime - 10)], | ||
["L", () => seekTo(videoElement.currentTime + 10)], | ||
["K", () => togglePlay()], | ||
["Space", () => togglePlay()], | ||
["m", () => setMuted(!muted)], | ||
["0", () => seekTo(0)], | ||
]); | ||
return ( | ||
<Box | ||
w="100%" | ||
h="100%" | ||
style={{ position: "relative" }} | ||
> | ||
<Box | ||
bg="dark.9" | ||
style={{ | ||
position: "absolute", | ||
height: "0%", | ||
width: "0%", | ||
zIndex: "-100", | ||
}} | ||
ref={videoContainerRef} | ||
/> | ||
<MusicControls /> | ||
</Box> | ||
); | ||
}; |
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
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,14 @@ | ||
import { Box, Stack } from "@mantine/core"; | ||
import { MusicPlayer } from "../../components/player/music/MusicPlayer"; | ||
import { TabsRenderer } from "../../components/tabs/TabsRenderer"; | ||
|
||
export const LayoutDesktopMusic = () => { | ||
return ( | ||
<Stack gap={0} h="calc(100vh - var(--app-shell-header-height))" style={{ overflow: "clip" }}> | ||
<Box p="sm"> | ||
<MusicPlayer /> | ||
</Box> | ||
<TabsRenderer isMobile /> | ||
</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