This repository has been archived by the owner on Nov 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(using it to mock mGBA frame placement for now)
- Loading branch information
Showing
9 changed files
with
124 additions
and
110 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
Binary file not shown.
This file was deleted.
Oops, something went wrong.
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
Binary file not shown.
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,47 @@ | ||
import { forwardRef, useState } from "react"; | ||
import BiosAnimation from "../../assets/bios_animation.mp4"; | ||
import { forwardRef, useRef } from "react"; | ||
import biosAnimation from "/bios_animation.mp4"; | ||
|
||
interface IntroAnimationPlayerProps { | ||
onVideoEnded?: () => void; | ||
volumePercentage?: number; | ||
isPlaying?: boolean; | ||
muted?: boolean; | ||
} | ||
const IntroAnimationPlayerPlayer = forwardRef(function _introAnimationPlayer( | ||
{ onVideoEnded = () => {} }: IntroAnimationPlayerProps, | ||
ref: React.Ref<HTMLVideoElement> | ||
const IntroAnimationPlayer = forwardRef(function _introAnimationPlayer( | ||
{ | ||
onVideoEnded = () => {}, | ||
volumePercentage = 1, | ||
isPlaying = false, | ||
muted = false, | ||
}: IntroAnimationPlayerProps, | ||
parentRef | ||
) { | ||
const [isVideoEnded, setIsVideoEnded] = useState(false); | ||
const handleVideoEnded = () => { | ||
setIsVideoEnded(true); | ||
onVideoEnded(); | ||
}; | ||
const localRef = useRef<HTMLVideoElement | null>(null); | ||
|
||
if (localRef.current) { | ||
localRef.current.volume = volumePercentage; | ||
if (isPlaying) { | ||
void localRef.current.play(); | ||
} else { | ||
localRef.current.pause(); | ||
} | ||
} | ||
|
||
return ( | ||
<> | ||
<video | ||
className={ | ||
isVideoEnded | ||
? "transition-opacity ease-out duration-700 opacity-0" | ||
: "transition-opacity ease-in duration-100 opacity-100" | ||
} | ||
preload="auto" | ||
ref={ref} | ||
onEnded={handleVideoEnded} | ||
onPlay={() => setIsVideoEnded(false)} | ||
> | ||
<source src={BiosAnimation} type="video/mp4" /> | ||
Your browser does not support HTML5 video. | ||
</video> | ||
ref={(ref) => { | ||
if (typeof parentRef === "function") parentRef(ref); | ||
else if (parentRef !== null) parentRef.current = ref; | ||
if (localRef !== null) localRef.current = ref; | ||
}} | ||
src={biosAnimation} | ||
onEnded={onVideoEnded} | ||
playsInline | ||
muted={muted} | ||
/> | ||
</> | ||
); | ||
}); | ||
|
||
export default IntroAnimationPlayerPlayer; | ||
export default IntroAnimationPlayer; |
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