Discord Player
Guides

Crossfade

Blend the end of one track into the start of the next.

You are reading the v8 docsDev

Crossfade overlaps the end of the playing track with the start of the next one. It is off by default.

Enable it

Turn it on for every queue when you create the Player:

import { Player } from 'discord-player';

const player = new Player({
  crossfade: { enabled: true, durationMs: 5000, curve: 'adaptive' },
  send,
});

Or for one queue:

const queue = await player.createQueue(guildId, {
  playback: {
    crossfade: { enabled: true, durationMs: 8000, prepareBeforeMs: 30_000 },
  },
});

A queue setting replaces the Player setting. Use crossfade: false to disable it for one queue.

OptionDefaultMeaning
enablednoneMust be true to opt in
durationMsNode policy (normally 5000)Length of the overlap
prepareBeforeMsNode policy (normally 30000)How long before the fade starts the next track is prepared
curveNode policy (normally 'equalPower')'equalPower' or 'adaptive'

equalPower uses fixed equal-power gains. adaptive starts with those gains and applies bounded, smoothed attenuation based on the loudness difference between tracks, up to 6 dB; it never boosts. Remedia owns the mixing for both curves.

Omitting curve, durationMs, or prepareBeforeMs leaves that setting to the selected node's defaults. A queue setting replaces the whole Player setting rather than merging with it.

The settings apply when a voice session is created. To change them for a guild, delete and recreate its queue.

Crossfade costs CPU

Crossfade decodes both tracks to PCM and mixes them. This uses more CPU than playing a single track.

What you will observe

Queue tracks as usual. The queue prepares the next track shortly before the fade, using the same source plugins as normal playback.

During the overlap:

  • playerStart for the incoming track can fire before playerFinish for the outgoing track.
  • queue.currentTrack becomes the incoming track when its promotion is confirmed.
  • The incoming track stays in queue.tracks while staged and is removed on promotion.

Staging a track for a fade does not fire playerStart. If the incoming start notification is lost, the queue can recover promotion from the outgoing completion continuation or a reconnect snapshot of the next generation. Recovered starts have no raw Remedia event argument. Snapshots that have advanced beyond that generation cannot identify the reserved track and are not used to promote it.

How repeat modes behave

Repeat modeNext track
OFFThe next upcoming track
TRACKA new copy of the current track
QUEUEThe next upcoming track, and the finished track moves to the end
AUTOPLAYThe next upcoming track, or an early related-track lookup

When AUTOPLAY has no upcoming track, Remedia's preparation request starts related-track discovery on the current track's source plugin host. The selected track is queued and prepared through the same crossfade path as other upcoming tracks. If discovery finishes after natural completion, the same request supplies the next track for ordinary playback. Skip, seek, stop, queue changes, and queue deletion cancel pending discovery.

With shuffle on, the next track is chosen once when it is prepared, and that same track is used when the fade happens.

Controls during a fade

ActionResult
Skip, seek, stop, history navigationCancels the prepared track
Pause and resumeThe prepared track is kept
Removing or moving the prepared trackCancels it and chooses again
queue.clear()Cancels preparation. The current track keeps playing

Use queue methods to change upcoming tracks. Changing queue.tracks.store directly resets preparation.

If preparing the next track fails, you receive playerError and the queue continues normally.

Embedded and remote nodes

An embedded node supports crossfade directly.

A remote node must also have crossfade enabled and report it as available. In remedia.config.json on the server:

{
  "audio": {
    "crossfade": { "enabled": true }
  }
}

If the selected node does not support crossfade, playback continues without it and the Player emits a debug message. Guilds are never moved to another node to enable crossfade.

An explicit curve must appear in node.capabilities.crossfade.curves. Requesting an unsupported curve rejects session creation; Discord Player does not replace adaptive with equalPower. Older servers advertise only equalPower through the client's capability normalization. If automatic placement could choose an incompatible node, pin a capable node or use selectNode to choose one explicitly.

Remedia-discovered Tracks stay on their originating node, including during crossfade preparation. That node must support the requested curve and the source's plugin host; another node's adaptive capability cannot override this affinity.

Crossfade needs tracks long enough for the configured overlap.

Continue reading

Handle events

On this page