-
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.
chore: add multi-engine react demo app
- Loading branch information
1 parent
dd0dcc3
commit ec88eb0
Showing
81 changed files
with
1,419 additions
and
225 deletions.
There are no files selected for viewing
Binary file added
BIN
+7.97 MB
.../v7_linux_x86_64_0.113.0/3d90119e56180f8a6d47f21a39da9a5ca2094986f8cd26a9f3daaa8fa37e147f
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"jsc": { | ||
"target": "esnext", | ||
"parser": { | ||
"syntax": "typescript", | ||
"jsx": true | ||
}, | ||
"transform": { | ||
"react": { | ||
"runtime": "automatic" | ||
} | ||
}, | ||
"experimental": { | ||
"plugins": [["@swc/plugin-emotion", {}]] | ||
} | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+18.2 KB
.yarn/cache/@babel-helper-module-imports-npm-7.24.7-f60e66adbf-df8bfb2bb1.zip
Binary file not shown.
Binary file added
BIN
+9.92 KB
.yarn/cache/@babel-helper-string-parser-npm-7.24.8-133b2e71e1-6d1bf8f27d.zip
Binary file not shown.
Binary file added
BIN
+17.7 KB
.yarn/cache/@babel-helper-validator-identifier-npm-7.24.7-748889c8d2-86875063f5.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+58.8 KB
.yarn/cache/@emotion-babel-plugin-npm-11.12.0-690c383ac1-fe6f4522ea.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+17.2 KB
.yarn/cache/@emotion-is-prop-valid-npm-1.3.0-40d3d3718f-9b395dd973.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+9.07 KB
.yarn/cache/@emotion-use-insertion-effect-with-fallbacks-npm-1.1.0-cf34827cd6-33a10f44a8.zip
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+7.47 KB
.yarn/cache/@emotion-weak-memoize-npm-0.4.0-76aafb2333-db5da0e89b.zip
Binary file not shown.
Binary file removed
BIN
-3.79 KB
.yarn/cache/@snowpack-plugin-typescript-npm-1.2.1-b14f9f51b1-365eda9c03.zip
Binary file not shown.
Binary file renamed
BIN
+15.6 MB
...inux-x64-gnu-npm-1.6.13-a7b9aab3c6-10.zip → ...inux-x64-gnu-npm-1.7.26-3f9254c7bf-10.zip
Binary file not shown.
Binary file renamed
BIN
+23.7 KB
...core-npm-1.6.13-b33663c12e-ccb9c11d5f.zip → ...core-npm-1.7.26-df1a50f4e7-8fb43420bd.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+16.3 KB
.yarn/cache/eme-encryption-scheme-polyfill-npm-2.1.5-21de7f589b-e5ea6e6254.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+13.4 KB
.yarn/cache/hoist-non-react-statics-npm-3.3.2-e7b709e6c1-1acbe85f33.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
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,79 @@ | ||
import styled from "@emotion/styled"; | ||
import { Global } from "@emotion/react"; | ||
import { resetStyles, defaultStyles } from "./css-global"; | ||
import { useForm, useWatch } from "react-hook-form"; | ||
import { | ||
DecorativeLabel, | ||
FormContainer, | ||
FormLabel, | ||
FormSelect, | ||
} from "./form-elements"; | ||
import { Player } from "./player"; | ||
|
||
const Select = styled.select``; | ||
const Option = styled.option``; | ||
|
||
type FormValues = { | ||
engine: "shaka" | "hlsjs" | "native"; | ||
asset: string; | ||
}; | ||
|
||
export const App = () => { | ||
const { register, control } = useForm<FormValues>({ | ||
defaultValues: { | ||
engine: "native", | ||
asset: "", | ||
}, | ||
resetOptions: { | ||
keepDirtyValues: true, // user-interacted input will be retained | ||
keepErrors: true, // input errors will be retained with value update | ||
}, | ||
}); | ||
|
||
const { engine, asset } = useWatch<FormValues>({ control }); | ||
|
||
return ( | ||
<> | ||
<Global | ||
styles={` | ||
${resetStyles} | ||
${defaultStyles} | ||
`} | ||
/> | ||
<FormContainer> | ||
<FormLabel> | ||
<DecorativeLabel>Engine</DecorativeLabel> | ||
<FormSelect | ||
// eslint-disable-next-line | ||
{...register(`engine`)} | ||
> | ||
{["shaka", "hlsjs", "native"].map((engine) => ( | ||
<option key={engine} value={engine}> | ||
{engine} | ||
</option> | ||
))} | ||
</FormSelect> | ||
</FormLabel> | ||
<FormLabel> | ||
<DecorativeLabel>Asset</DecorativeLabel> | ||
<FormSelect | ||
// eslint-disable-next-line | ||
{...register(`asset`)} | ||
> | ||
{["1", "2", "3"].map((engine) => ( | ||
<option key={engine} value={engine}> | ||
{engine} | ||
</option> | ||
))} | ||
</FormSelect> | ||
</FormLabel> | ||
</FormContainer> | ||
|
||
<div> | ||
Selected engine: {engine} {asset} | ||
</div> | ||
|
||
<Player /> | ||
</> | ||
); | ||
}; |
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 { RefObject, useCallback } from "react"; | ||
|
||
export const useControls = ({ | ||
playing, | ||
videoRef, | ||
}: { | ||
playing: boolean; | ||
videoRef: RefObject<HTMLVideoElement>; | ||
}) => { | ||
const playPause = useCallback(() => { | ||
if (playing) videoRef.current?.pause(); | ||
if (!playing) videoRef.current?.play().catch(console.error); | ||
}, [videoRef.current, playing]); | ||
|
||
const skip = useCallback( | ||
(num: number) => { | ||
if (!videoRef.current) return; | ||
|
||
videoRef.current.currentTime = videoRef.current.currentTime + num; | ||
}, | ||
[videoRef.current, playing], | ||
); | ||
|
||
return { | ||
playPause, | ||
skip, | ||
}; | ||
}; |
Oops, something went wrong.