Autoplay
When autoplay is on and the queue ends, Raya finds a related track and keeps playing.
new Raya({ nodes, connector, playerDefaults: { autoplay: true } }); // every playerplayer.setAutoplay(true); // one playerHow related tracks are found
Section titled “How related tracks are found”For the track that just finished, Raya tries these in order and plays the first result that wasn’t played recently (matched by id or by title):
-
The source’s own recommendations
- YouTube: the video’s YouTube mix
- Spotify:
sprec:mix:track:<id>, thensprec:seed_tracks=<id> - Deezer, Yandex, VK, Tidal, Qobuz, JioSaavn: LavaSrc’s
dzrec:,ymrec:,vkrec:,tdrec:,qbrec:,jsrec:
-
A Spotify radio from the ISRC, for tracks from other services, when your node has LavaSrc Spotify.
-
More from the same artist: first on the same source, then on your
defaultSearchSource, then on YouTube.
Queries for sources your Lavalink doesn’t have are skipped, based on the node’s /v4/info.
Autoplayed tracks inherit the requester of the track that finished. After three load failures in a row, autoplay stops trying and the queue ends, so a broken source can’t cause an endless loop.
See what it’s doing
Section titled “See what it’s doing”Turn on debugging to log every attempt:
[Raya] [Player 1234] autoplay "sprec:mix:track:0VjIjW4GlUZAMYd2vXMi3b" -> error (Recommendations need Extended quota mode)[Raya] [Player 1234] autoplay "spsearch:The Weeknd" -> search (10 tracks), picked "Save Your Tears"Custom autoplay
Section titled “Custom autoplay”Replace the strategy with your own. Return a track, or null to end the queue:
new Raya({ nodes, connector, autoplayResolver: async (player, lastTrack) => { const result = await player.search(`${lastTrack.info.author} live`, { source: 'youtube', requester: lastTrack.requester, }); return result.tracks.find((t) => t.info.identifier !== lastTrack.info.identifier) ?? null; },});The built-in pieces are exported if you want to extend them:
import { defaultAutoplay, relatedQueries } from 'raya.js';
relatedQueries(player, track); // the candidate queries, best first