103 lines
3.1 KiB
TypeScript
103 lines
3.1 KiB
TypeScript
// Metro module 8123 (f8124).
|
|
import { useState, useEffect, useCallback } from "react";
|
|
import AccessibilityStore from "../../a11y/AccessibilityStore";
|
|
import { create } from "../../../_bundle/Module644";
|
|
import { batchUpdates } from "../../../_bundle/Module705";
|
|
import { useMediaPlayerMutedStore } from "./MediaPlayerMuteManager";
|
|
import { createStyles } from "../../../design/components/Styles/native/createStyles";
|
|
import { useStateFromStores } from "../../../_bundle/Module589";
|
|
import { MediaViewerSourcesStore, removeSpoiler } from "./useMediaViewerSources";
|
|
import usePrevious from "../../../hooks/usePrevious";
|
|
import { supportOverlayVideoControls } from "./MediaSourceUtil";
|
|
import MediaSlider from "./components/MediaSlider";
|
|
let useStyles;
|
|
let c5158_7 = create(() => ({
|
|
controls: void 0,
|
|
paused: false
|
|
}));
|
|
useStyles = createStyles({
|
|
slider: {
|
|
marginBottom: 8
|
|
}
|
|
});
|
|
export default function useVideoControls(a0, a1, a2) {
|
|
let c16271_4, c16271_5, videoURI, c16271_7;
|
|
let c16271_0 = a0;
|
|
const styles = useStyles();
|
|
const stateFromStores = useStateFromStores([AccessibilityStore], () => AccessibilityStore.useReducedMotion);
|
|
let [paused2, setState] = useState(false);
|
|
const state = MediaViewerSourcesStore.useState((a0) => a0.spoilerIndexes.has(c16271_0));
|
|
c16271_4 = state;
|
|
const previous = usePrevious(a0);
|
|
c16271_5 = previous;
|
|
const r38 = a2 != null && supportOverlayVideoControls(a1);
|
|
let portal = a1.portal;
|
|
if (portal == null) {
|
|
portal = a1.videoURI;
|
|
}
|
|
videoURI = portal;
|
|
const previous2 = usePrevious(videoURI);
|
|
c16271_7 = previous2;
|
|
useEffect(() => {
|
|
if (c16271_5 !== c16271_0 && c16271_5 != null && videoURI != null && c16271_7 !== videoURI) {
|
|
a2.seek(0);
|
|
const r10 = c16271_4 || stateFromStores;
|
|
a2.pause(r10);
|
|
setState(r10);
|
|
}
|
|
}, [a2, videoURI, stateFromStores, previous2, state, previous, a0]);
|
|
const callback = useCallback(() => {
|
|
removeSpoiler(c16271_0);
|
|
}, [a0]);
|
|
if (r38) {
|
|
return <MediaSlider key={videoURI} style={styles.slider} controls={a2} paused={paused2} setPaused={setState} onPlayPress={callback} />;
|
|
}
|
|
};
|
|
export { c5158_7 as useVideoStateStore };
|
|
export function initVideoStateStore() {
|
|
batchUpdates(() => {
|
|
c5158_7.setState({
|
|
controls: void 0,
|
|
paused: false
|
|
});
|
|
});
|
|
}
|
|
export function setMuted(isMuted) {
|
|
batchUpdates(() => {
|
|
useMediaPlayerMutedStore.setState({
|
|
isMuted
|
|
});
|
|
});
|
|
}
|
|
export function toggleMuted() {
|
|
batchUpdates(() => {
|
|
useMediaPlayerMutedStore.setState((state) => ({
|
|
isMuted: !state.isMuted
|
|
}));
|
|
});
|
|
}
|
|
export function setVideoStateControls(controls) {
|
|
batchUpdates(() => c5158_7.setState({
|
|
controls
|
|
}));
|
|
}
|
|
export function setPausedState(paused) {
|
|
batchUpdates(() => c5158_7.setState({
|
|
paused
|
|
}));
|
|
}
|
|
export function tryPauseCurrentVideo() {
|
|
const controls2 = c5158_7.getState().controls;
|
|
if (controls2 != null) {
|
|
controls2.pause(true);
|
|
}
|
|
}
|
|
export function unpauseCurrentVideoIfNeeded() {
|
|
if (!c5158_7.getState().paused) {
|
|
const controls2 = c5158_7.getState().controls;
|
|
if (controls2 != null) {
|
|
controls2.pause(false);
|
|
}
|
|
}
|
|
}
|