import { getPlaybackState, normalizePlaybackState } from '../lib/spotify-api.ts' import type { PlaybackStateParams } from '../lib/export-types.ts' /** * Read the current Spotify playback state. * @returns Normalized playback, or `{ ok: true, nothing_playing: true }` when idle. * @example * import playbackState from 'kody:@kody/spotify/playback-state' * const state = await playbackState() */ export default async function playbackState(params: PlaybackStateParams = {}) { const result = await getPlaybackState(params) if (result.nothingPlaying) { return { ok: true, nothing_playing: true, integration: result.integration } } return { ...normalizePlaybackState(result.playback), integration: result.integration } }