Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | import React, { useEffect } from "react"; import { Song } from "shared/lib/uge/song/Song"; import trackerActions from "store/features/tracker/trackerActions"; import API from "renderer/lib/api"; import { MusicDataPacket } from "shared/lib/music/types"; import { useAppDispatch, useAppSelector } from "store/hooks"; interface UgePlayerProps { data: Song | null; onChannelStatusUpdate?: (channels: boolean[]) => void; } export const UgePlayer = ({ data, onChannelStatusUpdate }: UgePlayerProps) => { const dispatch = useAppDispatch(); useEffect(() => { API.music.openMusic(); return function close() { API.music.closeMusic(); }; }, []); const play = useAppSelector((state) => state.tracker.playing); useEffect(() => { const listener = (_event: unknown, d: MusicDataPacket) => { switch (d.action) { case "initialized": Iif (data) { API.music.sendToMusicWindow({ action: "load-song", song: data, }); } break; case "loaded": dispatch(trackerActions.playerReady(true)); break; case "muted": Iif (onChannelStatusUpdate) { onChannelStatusUpdate(d.channels); } break; } }; const unsubscribeMusicData = API.events.music.data.subscribe(listener); return () => { unsubscribeMusicData(); }; }, [onChannelStatusUpdate, play, data, dispatch]); useEffect(() => { if (play && data) { console.log("PLAY"); API.music.sendToMusicWindow({ action: "play", song: data, }); } else { API.music.sendToMusicWindow({ action: "stop", }); } }, [play, data]); return <div />; }; |