Discord Player
Guides

Playback controls

Pause, resume, seek, change volume, skip, and read playback position.

You are reading the v8 docsDev

Controls are asynchronous because they talk to Remedia. Await them before you reply to a user.

const queue = player.getQueue(guildId);

if (!queue) return;

await queue.node.pause();
await queue.node.resume();
await queue.node.seek(60_000); // Milliseconds
await queue.node.setVolume(75); // 0 to 200 percent

Skip, stop, and leave

CallEffect
await queue.skip()End the current track and start the next. Returns the next track or null
await queue.skipTo(trackOrIndex)Skip ahead to an upcoming track
await queue.jump(trackOrIndex)Same as skipTo()
await queue.stop()Stop playback and keep upcoming tracks
await queue.destroy()Stop, leave voice, and delete the queue

Use these queue methods for commands. queue.node.stopSession() and queue.node.play(source) control the audio session directly and bypass the queue.

Read the position

const elapsed = queue.node.playbackTime; // milliseconds
const duration = queue.node.totalDuration; // milliseconds
const timestamp = queue.node.getTimestamp(); // { current, total, progress } or null
const bar = queue.node.createProgressBar({ length: 20 });

getTimestamp() returns null when no track is selected. An unknown duration produces zero progress.

playbackTime prefers Remedia’s live source-media clock, keeping progress aligned with the source duration under filters such as nightcore and vaporwave. If that clock is unavailable, it uses the latest source position snapshot, then output elapsed time. It starts at zero for each new track and moves to the source seek target after a seek. streamTime uses the same clock, and progress is capped at 100.

These clocks estimate progress; they do not measure what a Discord listener has heard. Raw Remedia session.position separates source time (mediaMs) from submitted output time (submittedMs). Discord does not report an audible sample position, so playedMs can be null.

Seek

await queue.node.seek(90_000);

Whether a seek works depends on the source:

  • Files, owned buffers, and seekable HTTP resources can seek when the demuxer supports it.
  • Readables and plugin media grants are normally forward-only. Forward seeks decode and discard audio, and decoder read-ahead can make an earlier position unavailable.
  • Knowing a duration does not guarantee that a source can seek. Handle rejections for unsupported inputs and positions.

Fallback seeking

Opt in when creating the queue's voice session:

await queue.connect({ channelId, enableFallbackSeeking: true });

This setting cannot be changed on an existing session. A remote node must advertise fallback-seeking support; requesting it on an unsupported node rejects session creation.

Remedia can reopen an eligible non-seekable source in a second decoder while the current source keeps playing. An operation source is reopened by executing its operation again; a one-shot Readable cannot be reopened. This allows backward seeks on eligible operation sources as well as seeks on HTTP resources without usable range support. The seek can take seconds, so remote requestTimeoutMs must allow for preparation.

The applied position includes source time that elapsed during preparation. playerSeek carries the native playbackSeeked event: requestedPositionMs is the target, positionMs is where playback continues, and fallback identifies a replacement. Use the applied position for progress. A fallback seek can advance the native generation without firing playerStart for another Track. See Remedia's seeking behavior for cancellation and timing details.

Handle the rejection and tell the user:

try {
  await queue.node.seek(positionMs);
} catch (error) {
  await interaction.reply('This track does not support seeking there.');
}

Volume

setVolume() takes a percentage from 0 to 200. The default is 100. You can also set it when connecting:

await queue.connect({ channelId, volume: 70 });

While crossfading

During a crossfade, currentTrack is the incoming track. Skip, seek, and stop apply to it. See crossfade.

Continue reading

Navigate history

On this page