Kinetik UI

Now Playing

.md

A dark music widget: the cover springs forward on play, the icon morphs and progress runs on the UI thread.

v1.1.0Live on webreact-native-reanimatedreact-native-svgreact-native-worklets
Component preview

Installation

Kinetik CLI
npx kinetik-ui add now-playing

The CLI copies the source and installs native dependencies with npx expo install, so versions match your Expo SDK. With shadcn: npx shadcn@latest add https://kinetik-ui.dev/r/now-playing.json

Install manually

  1. Install dependencies
    npx expo install react-native-reanimated react-native-svg react-native-worklets
  2. Copy the source files
    • components/kinetik/now-playing.tsx
    View source files

Usage

import { NowPlaying } from '@/components/kinetik/now-playing';

<NowPlaying
  tracks={queue.map((t) => ({
    id: t.id,
    title: t.title,
    subtitle: t.artist,
    cover: { uri: t.artwork },
    duration: t.seconds,
  }))}
  onTrackChange={(t) => player.load(t.id)}
  onPlayingChange={(on) => (on ? player.play() : player.pause())}
/>;

With a real audio engine

Pass playing, position and trackId from your player, and the widget follows it instead of keeping its own clock. Buffering, a seek from the lock screen or a skip from headphones then shows up as it happens.

const { playing, position, trackId } = usePlayerState(); // from your audio library

<NowPlaying
  tracks={tracks}
  playing={playing}
  position={position}
  trackId={trackId}
  onPlayingChange={(on) => (on ? player.play() : player.pause())}
  onTrackChange={(t) => player.skipTo(t.id)}
  onSeek={(seconds) => player.seekTo(seconds)}
/>;

When to use

  • A compact player for a queue: a widget, a mini player or a now-playing sheet header.

When not to use

  • When people need to scrub precisely, say through podcasts or audiobooks: the bar seeks on a tap, not a drag.

Notes

  • Without position it keeps its own clock, which is fine for a preview or a demo. With real audio, pass position so the audio engine stays the source of truth. Updates a few times a second are enough: the bar glides between them.

  • Each of playing, position and trackId is optional and independent. Whatever you leave unset, the widget keeps on its own.

  • onSeek fires for a tap on the bar, a screen-reader step and Previous restarting the track.

  • Previous restarts the track if more than three seconds have played, as most players do; otherwise it goes back a track.

  • Tap the progress bar to seek. Screen readers adjust it in ten-second steps.

  • On its own clock, when a track ends the next one starts. The queue wraps around.

  • clock(seconds) is exported for the same 1:09 format elsewhere.

  • The widget is dark on both themes. accent colours the progress and the play button.

Props

NowPlayingProps

PropTypeDefaultDescription
tracksrequiredreadonly NowPlayingTrack[]—
autoPlaybooleanfalseStart playing at once. Defaults to false. Ignored when `playing` is set.
playingboolean—Whether it plays, owned by your app. Leave unset to let the player keep its own state.
positionnumber—Seconds into the current track, reported by your audio engine. Setting it turns the player's own clock off: the bar and the time follow this value.
trackIdstring—The id of the current track, owned by your app (say, after a skip from the lock screen).
onTrackChange(track: NowPlayingTrack) => void—Called with the track that starts.
onPlayingChange(playing: boolean) => void—
onSeek(seconds: number) => void—Called with the seconds to jump to when the bar is tapped, stepped or Previous restarts.
accentstring'hsl(28, 96%, 54%)'Colour of the progress and the play button. Defaults to amber orange.
hapticsbooleantrueA tick on each control. Defaults to true.
styleStyleProp<ViewStyle>—

Performance and accessibility

Performance

Budget
Progress is one UI-thread timing per track; the time labels re-render four times a second while playing. Paused, nothing animates.
Measured

Pixel 9 emulator, API 35, release build · interaction median 1.00× the system Settings app on the same emulator (indicative only) · no frames drawn at rest · 174 MB app memory

Real-device measurement pending.

Accessibility

Reduced motion
Play, pause and skipping change state without the cover spring, slide or icon turn.
Screen readers
Title and subtitle read as one line; the progress is adjustable ("1:09 of 3:43", ten-second steps); Previous, Play/Pause and Next are buttons.
Touch target
Buttons are 44 pt tall; the progress bar's touch area is 44 pt tall.

Source files

components/kinetik/now-playing.tsx is in the Code tab of the preview above.