Skip to content
← Public packages

@kentcdodds/spotify

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

src/exports/set-volume.ts

21 lines · 909 B · TypeScript
import { setVolume } from '../lib/spotify-api.ts'
import type { SetVolumeParams } from '../lib/export-types.ts'

/**
 * Set playback volume on the active or named Spotify device (0–100).
 * 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, action 'volume-set', deviceId, volumePercent, and status.
 * @example
 * import setVolume from 'kody:@kentcdodds/spotify/set-volume'
 * const result = await setVolume({ volumePercent: 50, deviceName: 'Living Room' })
 * // => { ok: true, action: 'volume-set', deviceId: '...', volumePercent: 50, status: 204 }
 */
async function spotifySetVolume(params: SetVolumeParams = {}) {
	return await setVolume({
		...params,
		volumePercent: params.volumePercent ?? params.volume,
	})
}

export default spotifySetVolume