mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 21:06:42 +07:00
refactored playerbar component
This commit is contained in:
parent
6ca4c514bf
commit
df217b41f7
9 changed files with 78 additions and 53 deletions
17
src/utils/hooks/player/usePlayer.ts
Normal file
17
src/utils/hooks/player/usePlayer.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
import { useShallowSelect } from '~/utils/hooks/useShallowSelect';
|
||||
import { selectPlayer } from '~/redux/player/selectors';
|
||||
import { useCallback } from 'react';
|
||||
import { playerPause, playerPlay, playerSeek, playerStop } from '~/redux/player/actions';
|
||||
import { useDispatch } from 'react-redux';
|
||||
|
||||
export const usePlayer = () => {
|
||||
const { status, file } = useShallowSelect(selectPlayer);
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const onPlayerPlay = useCallback(() => dispatch(playerPlay()), [dispatch]);
|
||||
const onPlayerPause = useCallback(() => dispatch(playerPause()), [dispatch]);
|
||||
const onPlayerSeek = useCallback((pos: number) => dispatch(playerSeek(pos)), [dispatch]);
|
||||
const onPlayerStop = useCallback(() => dispatch(playerStop()), [dispatch]);
|
||||
|
||||
return { status, file, onPlayerPlay, onPlayerSeek, onPlayerPause, onPlayerStop };
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue