mirror of
https://github.com/movie-web/native-app.git
synced 2025-09-13 18:13:25 +00:00
feat: finish playback speed stuff
This commit is contained in:
@@ -1,18 +1,21 @@
|
||||
import { useCallback } from "react";
|
||||
import { useSharedValue } from "react-native-reanimated";
|
||||
|
||||
import { usePlayerStore } from "~/stores/player/store";
|
||||
|
||||
export const usePlaybackSpeed = () => {
|
||||
const speed = useSharedValue(1);
|
||||
const videoRef = usePlayerStore((state) => state.videoRef);
|
||||
|
||||
const changePlaybackSpeed = useCallback(
|
||||
(newValue: number) => {
|
||||
speed.value = newValue;
|
||||
if (videoRef) {
|
||||
void videoRef.setRateAsync(newValue, true);
|
||||
}
|
||||
},
|
||||
[speed],
|
||||
[videoRef],
|
||||
);
|
||||
|
||||
return {
|
||||
currentSpeed: speed,
|
||||
currentSpeed: videoRef?.props.rate ?? 1,
|
||||
changePlaybackSpeed,
|
||||
} as const;
|
||||
};
|
||||
|
Reference in New Issue
Block a user