diff options
| author | Factiven <[email protected]> | 2023-09-25 00:44:40 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-09-25 00:44:40 +0700 |
| commit | 1a85c2571690ba592ac5183d5eadaf9846fe532b (patch) | |
| tree | 3f3552c00cd49c0eeab5275275cf5cf5666e5027 /lib/hooks/watchPageProvider.js | |
| parent | Delete .github/workflows/deploy.yml (diff) | |
| download | moopa-4.1.0.tar.xz moopa-4.1.0.zip | |
Update v4.1.0 (#79)v4.1.0
* Update v4.1.0
* Update pages/_app.js
Diffstat (limited to 'lib/hooks/watchPageProvider.js')
| -rw-r--r-- | lib/hooks/watchPageProvider.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/hooks/watchPageProvider.js b/lib/hooks/watchPageProvider.js new file mode 100644 index 0000000..a9d707b --- /dev/null +++ b/lib/hooks/watchPageProvider.js @@ -0,0 +1,41 @@ +import React, { createContext, useContext, useState } from "react"; + +export const WatchPageContext = createContext(); + +export const WatchPageProvider = ({ children }) => { + const [theaterMode, setTheaterMode] = useState(false); + const [aspectRatio, setAspectRatio] = useState("16/9"); + const [playerState, setPlayerState] = useState({ + currentTime: 0, + isPlaying: false, + }); + const [autoplay, setAutoPlay] = useState(false); + const [marked, setMarked] = useState(0); + + const [userData, setUserData] = useState(null); + + return ( + <WatchPageContext.Provider + value={{ + theaterMode, + setTheaterMode, + aspectRatio, + setAspectRatio, + playerState, + setPlayerState, + userData, + setUserData, + autoplay, + setAutoPlay, + marked, + setMarked, + }} + > + {children} + </WatchPageContext.Provider> + ); +}; + +export function useWatchProvider() { + return useContext(WatchPageContext); +} |