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.

search-and-queue.ts
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.

playback-controls.ts
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 looping

Disconnect vs Destroy

Disconnection stops playback but keeps the player. Destruction removes the player entirely.

session-teardown.ts
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.playing vs player.paused: Different signals; use both to understand player state.
  • player.position: Computed value; use seek() to move the playback position.
  • player.isPlaying(): Check before calling play() to avoid redundant operations.