()
| 30 | }; |
| 31 | |
| 32 | export 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 | }; |
no test coverage detected