Getting Started
Player Lifecycle
Control playback with search, queue, play, pause, skip, seek, and destroy.
This guide covers the complete playback lifecycle: searching for tracks, managing the queue, runtime controls, and teardown.
Search & Queue
Search for tracks and add them to the queue.
import { } from 'hoshimi';
import type { } from 'hoshimi';
declare const : ;
const = await .({
: 'Daft Punk - Harder Better Faster Stronger',
: {
: '123',
: 'demo-user',
},
});
if (. === . || . === .) {
await ..(.[0]);
}Playback Control
Play, pause, skip, seek, adjust volume, and set loop modes.
import { } from 'hoshimi';
import type { } from 'hoshimi';
declare const : ;
// Connect and play
if (!.) await .();
if (!.()) await .();
// Control playback
await .(true); // pause
await .(false); // resume
await .(30_000); // seek to 30s
await .({ : 1 }); // skip to next
await .(150); // 150% volume
// Loop modes
.(.); // loop entire queue
.(.); // loop current track
.(.); // disable loopingDisconnect vs Destroy
Disconnection stops playback but keeps the player. Destruction removes the player entirely.
import { } from 'hoshimi';
import type { } from 'hoshimi';
declare const : ;
// Disconnect from voice (stops playback, keeps player)
await .();
// Destroy player (cleanup, removal)
await .({ : . });Important Notes
player.connected: Voice connection state, not playback state.player.playingvsplayer.paused: Different signals; use both to understand player state.player.position: Computed value; useseek()to move the playback position.player.isPlaying(): Check before callingplay()to avoid redundant operations.