1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.usePlayingState = exports.useTimelineSetFrame = exports.useTimelinePosition = exports.SetTimelineContext = exports.TimelineContext = void 0;
|
4 | const react_1 = require("react");
|
5 | exports.TimelineContext = (0, react_1.createContext)({
|
6 | frame: 0,
|
7 | playing: false,
|
8 | playbackRate: 1,
|
9 | rootId: '',
|
10 | imperativePlaying: {
|
11 | current: false,
|
12 | },
|
13 | setPlaybackRate: () => {
|
14 | throw new Error('default');
|
15 | },
|
16 | audioAndVideoTags: { current: [] },
|
17 | });
|
18 | exports.SetTimelineContext = (0, react_1.createContext)({
|
19 | setFrame: () => {
|
20 | throw new Error('default');
|
21 | },
|
22 | setPlaying: () => {
|
23 | throw new Error('default');
|
24 | },
|
25 | });
|
26 | const useTimelinePosition = () => {
|
27 | const state = (0, react_1.useContext)(exports.TimelineContext);
|
28 | return state.frame;
|
29 | };
|
30 | exports.useTimelinePosition = useTimelinePosition;
|
31 | const useTimelineSetFrame = () => {
|
32 | const { setFrame } = (0, react_1.useContext)(exports.SetTimelineContext);
|
33 | return setFrame;
|
34 | };
|
35 | exports.useTimelineSetFrame = useTimelineSetFrame;
|
36 | const usePlayingState = () => {
|
37 | const { playing, imperativePlaying } = (0, react_1.useContext)(exports.TimelineContext);
|
38 | const { setPlaying } = (0, react_1.useContext)(exports.SetTimelineContext);
|
39 | return (0, react_1.useMemo)(() => [playing, setPlaying, imperativePlaying], [imperativePlaying, playing, setPlaying]);
|
40 | };
|
41 | exports.usePlayingState = usePlayingState;
|
42 |
|
\ | No newline at end of file |