MCPcopy Index your code
hub / github.com/nukeop/nuclear / deriveCurrentTrack

Function deriveCurrentTrack

packages/player/src/remoteControl/useRemoteState.ts:21–41  ·  view source on GitHub ↗
(
  queue: Queue | null,
)

Source from the content-addressed store, hash-verified

19};
20
21const deriveCurrentTrack = (
22 queue: Queue | null,
23): { track: CurrentTrack; isLoading: boolean } | undefined => {
24 if (!queue || queue.items.length === 0) {
25 return undefined;
26 }
27
28 const item = queue.items[queue.currentIndex];
29 if (!item) {
30 return undefined;
31 }
32
33 return {
34 track: {
35 title: item.track.title,
36 artist: item.track.artists[0]?.name,
37 coverUrl: pickArtwork(item.track.artwork, 'cover', 208)?.url,
38 },
39 isLoading: item.status === 'loading',
40 };
41};
42
43const derivePlayback = (playback: PlaybackState | null) => {
44 const elapsed = playback?.seek ?? 0;

Callers 1

useRemoteStateFunction · 0.85

Calls 1

pickArtworkFunction · 0.90

Tested by

no test coverage detected