Skip to content

Reference

Spotify Connect mode

The opt in second mode for listening parties, where the party plays through your own Spotify app instead of the station stream. Built and not yet live. What it does, the states you can land in, every number it runs on, and what has to happen before it can be switched on.

Overview

A listening party normally carries one sound: the station stream, which everybody in the car hears at the same moment. That is the shipped behaviour and it is described in Radio and settings.

Spotify Connect mode is an opt in second mode for one listener at a time. Instead of hearing the station, your own Spotify app plays the same track at the same point, and the game stream is muted for you alone. Everybody else in the party carries on hearing the station. It is a per listener choice that changes nothing for anyone else.

The game never handles Spotify audio. It tells Spotify's own service, through your linked account, which track to play and where to be in it. Your Spotify app does the playing. This is the only lawful way to put real Spotify audio near this feature, and it is why the mode needs Premium and a device that is already awake.

Current status

Three things stand between this and a working feature, and only the first is close.

Piece

Where it lives

State

Game side conductor and panel

rp-core, four files plus changes to the party manager

Written, typechecks, not committed to main

The endpoint it calls

UCP API, POST /api/spotify/internal/party-sync

Written, not deployed. Returns 404 today

Playback permission on linked accounts

UCP Spotify link

Not granted. Existing links carry no playback scopes

The third is the one that decides the date. Every Spotify account already linked on the UCP was linked for search and identity only. Controlling playback needs different permissions, which means every player who wants this mode has to re authorise, and the UCP needs a route that asks for it. Until that exists, switching the mode on would give everyone not_linked and nothing else.

What a listener would do

  1. Link Spotify with playback permission

    On the UCP at https://ucp.roleplayproject.net/settings. A link made for search alone is not enough, and the panel will say not_linked until the permission is there.

  2. Have Premium and an awake device

    Spotify does not allow remote control of a Free account, and it will not play to an app that is fully closed. Open Spotify on your phone or desktop first.

  3. Turn Connect mode on in the party panel

    The game stream mutes for you alone and your Spotify app starts the current track at the current position. Everybody else keeps hearing the station.

  4. Resync if you drift

    /party resync puts you back on the party's position. There is a ten second cooldown on it.

  5. Turn it off, or leave

    Either brings the station back. Nothing is left playing on your device.

How it stays in time

The conductor keeps one anchor per party, not one per listener. The anchor is the wall clock time at which the current track would have been at zero. A listener's position is then simply the time since that anchor, which costs nothing to compute and never drifts between listeners.

The station's own reported progress is sampled every tick. If it disagrees with the anchor by more than the anchor tolerance, the anchor moves and the jump is recorded. A recorded jump larger than the drift tolerance is what triggers a seek for listeners who have not been spoken to since it happened.

Three operations are ever sent: play when the track changed, seek when the anchor jumped or the heartbeat came due, and stop when the mode ends. Everything is batched per party, and a track within its final ten seconds is left alone rather than being started twice.

States

The panel shows one of these. Anything other than playing and starting means the station is still your sound.

State

What it means

off

Mode is not on. You hear the station

starting

Instruction sent, waiting for your device to pick it up

playing

Your Spotify is carrying the party

no_track

The party is between tracks

not_linked

No Spotify account linked, or no playback permission on the link

no_premium

The account is Free. Spotify does not allow remote control without Premium

no_device

No Spotify app awake to play to. Open Spotify and press resync

reconnect

The link expired or lacks a permission it used to have. Re link on the UCP

not_approved

The account is not registered against this Spotify application

rate_limited

Spotify is throttling us. It clears on its own

failed

The instruction did not take. Resync, or turn it off and on

unavailable

The mode is switched off server side. This is the state today

Numbers

Setting

Constant

Value

Tick

PARTY_PERSONAL_TICK_MS

1 s

Send lead

PARTY_PERSONAL_LEAD_MS

700 ms

Anchor tolerance

PARTY_PERSONAL_ANCHOR_TOLERANCE_MS

2 s

Drift tolerance before a seek

PARTY_PERSONAL_DRIFT_TOLERANCE_MS

2.5 s

Minimum gap between seeks

PARTY_PERSONAL_RESEEK_MIN_MS

20 s

Heartbeat seek

PARTY_PERSONAL_HEARTBEAT_MS

90 s

Tail left alone

PARTY_PERSONAL_TAIL_MS

10 s

Grace after a play

PARTY_PERSONAL_START_GRACE_MS

1.5 s

Listeners per request

PARTY_PERSONAL_BATCH_MAX

20

Requests per tick

PARTY_PERSONAL_REQUESTS_PER_TICK

2

Toggle cooldown

PARTY_PERSONAL_TOGGLE_COOLDOWN_MS

3 s

Resync cooldown

PARTY_PERSONAL_RESYNC_COOLDOWN_MS

10 s

Server wide operations budget

PARTY_PERSONAL_GLOBAL_OPS_PER_MIN

240 per minute

Endpoint timeout

PARTY_PERSONAL_REQUEST_TIMEOUT_MS

10 s

The global budget is a ceiling on how hard the whole server may push Spotify in any minute. Plays are always spent first and seeks take what is left, so a busy night degrades into slightly looser sync rather than into failed starts.

What it deliberately does not do

  • It does not play Spotify audio through the game. It asks your app to play, and your app plays.

  • It does not change what anybody else hears. The station keeps carrying the party.

  • It does not queue, buy, or store music, and it holds no audio of any kind.

  • It does not work without Premium, and that is Spotify's rule, not ours.

Before it can ship

  1. Commit the game side

    Four new files and changes to the party manager, currently uncommitted.

  2. Deploy the application side of the endpoint guard

    The web server already refuses these paths from outside. The matching check inside the application is written and goes out with the next UCP deployment.

  3. Build the re authorisation route on the UCP

    Existing links carry no playback permission, so every interested player has to link again through a route that asks for it. This is the long pole.

  4. Deploy the UCP API

    That restarts shared sign on, so it needs a scheduled slot rather than being done casually.

  5. Switch on the master switch

    LP_SPOTIFY_PERSONAL_ENABLED in the server environment. It is off, and with it off the mode reports unavailable and costs nothing.

Related: Radio and settings, Default keys.

Was this page helpful?

1 found it helpful