MCPcopy
hub / github.com/nukeop/nuclear / useRemoteActions

Function useRemoteActions

packages/player/src/remoteControl/useRemoteActions.ts:32–52  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30};
31
32export const useRemoteActions = (): RemoteActions => {
33 const getState = () => useRemoteStore.getState();
34
35 return {
36 onPlayPause: () => postAction('/api/playback/toggle'),
37 onNext: () => postAction('/api/playback/next'),
38 onPrevious: () => postAction('/api/playback/previous'),
39 onSeek: (percent: number) => {
40 const duration = getState().playback?.duration ?? 0;
41 postAction('/api/playback/seek', { seconds: (percent / 100) * duration });
42 },
43 onShuffleToggle: () => {
44 const shuffle = getState().settings.shuffle;
45 postAction('/api/playback/shuffle', { enabled: !shuffle });
46 },
47 onRepeatToggle: () => {
48 const repeat = getState().settings.repeat;
49 postAction('/api/playback/repeat', { mode: nextRepeatMode[repeat] });
50 },
51 };
52};

Callers 1

RemoteControlFunction · 0.90

Calls 2

postActionFunction · 0.85
getStateFunction · 0.85

Tested by

no test coverage detected