From 04c4dfd13a3d898fb9bc41165eff50893f3a7d2b Mon Sep 17 00:00:00 2001 From: Alex Kim Date: Fri, 6 Dec 2024 15:08:33 +1100 Subject: [PATCH 1/2] Fixed bugs for skip intro button still being able to be clicked once it is gone past the time frame --- .../video-player/controls/BrightnessSlider.tsx | 3 ++- components/video-player/controls/Controls.tsx | 14 ++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/components/video-player/controls/BrightnessSlider.tsx b/components/video-player/controls/BrightnessSlider.tsx index 33fe0e0f..3cbbd460 100644 --- a/components/video-player/controls/BrightnessSlider.tsx +++ b/components/video-player/controls/BrightnessSlider.tsx @@ -14,10 +14,11 @@ const BrightnessSlider = () => { useEffect(() => { const fetchInitialBrightness = async () => { const initialBrightness = await Brightness.getBrightnessAsync(); + console.log("initialBrightness", initialBrightness); brightness.value = initialBrightness * 100; }; fetchInitialBrightness(); - }, [brightness]); + }, []); const handleValueChange = async (value: number) => { brightness.value = value; diff --git a/components/video-player/controls/Controls.tsx b/components/video-player/controls/Controls.tsx index 0e8c5451..f42600e3 100644 --- a/components/video-player/controls/Controls.tsx +++ b/components/video-player/controls/Controls.tsx @@ -344,9 +344,10 @@ export const Controls: React.FC = ({ { position: "absolute", right: insets.right, - bottom: insets.bottom + 50, + bottom: insets.bottom + 55, }, ]} + pointerEvents={showSkipButton ? "auto" : "none"} className={`z-10 p-4 ${showSkipButton ? "opacity-100" : "opacity-0"} `} @@ -561,10 +562,15 @@ export const Controls: React.FC = ({ opacity: showControls ? 1 : 0, }, ]} - pointerEvents={showControls ? "auto" : "none"} + pointerEvents={showControls ? "box-none" : "none"} className={`flex flex-col p-4`} > - + {item?.Name} {item?.Type === "Episode" && ( {item.SeriesName} @@ -577,7 +583,7 @@ export const Controls: React.FC = ({ )} Date: Fri, 6 Dec 2024 16:42:58 +1100 Subject: [PATCH 2/2] Refactored code, so that way the skip intro button is not using absolute positioning --- components/video-player/controls/Controls.tsx | 103 +++++++----------- .../video-player/controls/SkipButton.tsx | 39 +++++++ 2 files changed, 77 insertions(+), 65 deletions(-) create mode 100644 components/video-player/controls/SkipButton.tsx diff --git a/components/video-player/controls/Controls.tsx b/components/video-player/controls/Controls.tsx index f42600e3..d814e3c5 100644 --- a/components/video-player/controls/Controls.tsx +++ b/components/video-player/controls/Controls.tsx @@ -51,6 +51,7 @@ import * as Haptics from "expo-haptics"; import DropdownViewDirect from "./dropdown/DropdownViewDirect"; import DropdownViewTranscoding from "./dropdown/DropdownViewTranscoding"; import BrightnessSlider from "./BrightnessSlider"; +import SkipButton from "./SkipButton"; interface Props { item: BaseItemDto; @@ -339,60 +340,6 @@ export const Controls: React.FC = ({ )} - - - Skip Intro - - - - - - Skip Credits - - - { toggleControls(); @@ -568,19 +515,45 @@ export const Controls: React.FC = ({ - {item?.Name} - {item?.Type === "Episode" && ( - {item.SeriesName} - )} - {item?.Type === "Movie" && ( - {item?.ProductionYear} - )} - {item?.Type === "Audio" && ( - {item?.Album} - )} + + {item?.Name} + {item?.Type === "Episode" && ( + {item.SeriesName} + )} + {item?.Type === "Movie" && ( + {item?.ProductionYear} + )} + {item?.Type === "Audio" && ( + {item?.Album} + )} + + + + + void; + showButton: boolean; + buttonText: string; +} + +const SkipButton: React.FC = ({ + onPress, + showButton, + buttonText, +}) => { + return ( + + + {buttonText} + + + ); +}; + +const styles = StyleSheet.create({ + button: { + backgroundColor: "rgba(0, 0, 0, 0.75)", + borderRadius: 5, + paddingHorizontal: 10, + paddingVertical: 15, + borderWidth: 2, + borderColor: "#5A5454", + }, + text: { + color: "white", + fontWeight: "bold", + }, +}); + +export default SkipButton;