Skip to content
← Public packages

@kentcdodds/spotify

Spotify playback, playlist, search, library, and device helpers.

src/exports/seek.ts

21 lines · 792 B · TypeScript
import { seek } from '../lib/spotify-api.ts'
import type { SeekParams } from '../lib/export-types.ts'

/**
 * Seek to a position in the currently playing Spotify track.
 * Prefer `deviceName` when targeting a device; omit selectors for the active device.
 * All params accept an optional `account` ('personal' | 'family', default 'personal').
 * @returns Confirmation with ok, positionMs, deviceId, and status.
 * @example
 * import spotifySeek from 'kody:@kentcdodds/spotify/seek'
 * const result = await spotifySeek({ positionMs: 30000 })
 * // => { ok: true, positionMs: 30000, deviceId: null, status: 204 }
 */
async function spotifySeek(params: SeekParams = {}) {
	return await seek({
		...params,
		positionMs: params.positionMs ?? params.position_ms,
	})
}

export default spotifySeek