Player control and audio output
Spotifast turns Spotify playback state into one local player experience. It accepts commands from the app and desktop controls, keeps the local device in step with Spotify Connect, shapes the sound for the chosen output, and records enough local listening history to support recent-play views. Local playback can use the built-in player or the optional Spotify Soloist player. The wider device model is described in Music playback and device control, while network targets are described in Casting and network devices.
Playback state
The local player is the app's view of playback on this computer. It combines the current item, position, transport state, volume, shuffle and repeat choices, connection state, and user-facing errors into a snapshot that the UI can consume.
State model
The player moves through Stopped, Loading, Playing, and Paused. A position continues to advance only while the state is playing, so the UI can show a current time between player updates. Track and seek sequence values let the UI tell a new play of the same item from an unchanged snapshot.
The local session can remain ready even when Spotify marks this device inactive. A new load activates it again. If the session ends, the player keeps enough state to resume the item after reconnect, unless the app is shutting down.
References: src/player.rs• L107-245 src/player.rs• L484-617 src/player.rs• L977-987
Playback providers
Spotifast offers two ways to play on this computer. The built-in player acts as a Spotify Connect device and gives Spotifast direct control of its local output. Spotify Soloist is an optional managed Spotify player that Spotifast downloads, updates, and pairs with the Spotify app.
Both providers require a Premium account. Browser sign-in uses the listener's registered Spotify Client ID, and Soloist also needs a personal key. Setup keeps these access steps separate from the playback controls, so a provider can be changed without changing the app's library view.
References: src/player.rs• L502-617 src/…/login.rs• L165-187 src/…/soloist.rs• L309-360 src/…/soloist.rs• L671-733 src/…/settings.rs• L704-750
Playback commands
Playback commands provide one control language for local playback. They cover transport actions, queue changes, seeking, volume, shuffle, repeat, loading a context or set of items, and taking over an active Connect session.
The app chooses a local or remote target before it sends a command. Local commands go through the player session. Remote commands use the device service instead, so a control can affect a phone, speaker, or other target without changing the local audio path.
The player treats volume dragging as a preview until release. This gives immediate local feedback without sending a network update for every slider position. A committed value is then sent to Spotify Connect. Song menus use the same command path for Play next, Add to queue, and queue removal when the active target permits local queue changes.
References: src/player.rs• L288-316 src/player.rs• L877-951 src/…/widgets.rs• L677-775 src/…/widgets.rs• L1174-1239
Audio output
The audio path turns decoded Spotify audio into sound from one selected system output. It opens the output when playback needs it, follows the system default when appropriate, and reports output faults to the app instead of taking down the player.
Output sinks
The primary sink is the local system output. A saved device is preferred when it is present; otherwise playback falls back to the default output. Older saved names can be resolved to stable device identifiers when the device opens.
The sink keeps a short queue so the decoder and device can work independently. Play, pause, stop, and explicit track changes use short fades. An explicit replacement also discards old queued sound before the new item is allowed through. This prevents stale audio from playing after a skip or seek.
If an output disappears, the sink tries to reopen it and follows a changed system default. If no output can be opened, the player reports a readable error and remains available as a Spotify Connect target.
Settings expose the device identity, stream quality, output buffer, loudness normalization, gapless playback, and audio cache as local playback choices. Changes that affect the running engine are marked for an explicit playback restart.
References: src/sink.rs• L1-13 src/sink.rs• L91-201 src/sink.rs• L722-903 src/sink.rs• L912-980 src/…/settings.rs• L704-822 src/…/settings.rs• L1080-1095
Signal path
Local audio passes through the sound-shaping stages before it reaches the sink. Equalizer and channel settings shape the signal first. A limiter then protects the final output from peaks. The visualizer reads a post-equalizer signal before output volume, so volume changes do not change the visualizer's analysis.
The path keeps local audio separate from remote playback. Equalizer, balance, mono, and output volume affect sound on this computer only. They do not change what another Spotify device receives.
The main signal flow is:
flowchart LR
D[Decoded Spotify audio] --> E[Equalizer and channel shaping]
E --> T[Visualizer tap]
E --> L[Peak limiter]
L --> R[Sample-rate conversion when needed]
R --> V[Output volume]
V --> S[Selected system sink]
References: src/player.rs• L619-681 src/player.rs• L997-1055 src/vis.rs• L1-7 src/vis.rs• L102-121 src/limiter.rs• L1-13
Equalizer behavior
The equalizer provides Winamp-style local sound shaping. It has a preamp and ten frequency bands, plus balance and mono controls that apply to local playback.
Equalizer settings
The equalizer is off and flat by default. The preamp and each band stay within a range of -12 to +12 dB. Presets set the band curve, and saved presets also keep their preamp value. Balance lowers one channel without raising the other. Mono replaces the two channels with their shared middle signal.
The UI can change these settings while audio plays. The player applies a changed setting to later audio without changing the selected device or the Spotify playback state. Settings search exposes the equalizer as a local playback feature, and saved presets can be applied or removed without affecting Spotify devices.
References: src/eq.rs• L1-8 src/eq.rs• L26-80 src/…/settings.rs• L2238-2350 src/…/settings.rs• L2865-3045
Equalizer controls
The Winamp equalizer window exposes the power switch, preamp, bands, presets, volume, and balance. Its full and shaded forms use the same app settings, so changing the view does not create a second audio configuration.
References: src/…/equalizer.rs• L28-123 src/…/equalizer.rs• L125-239 src/…/equalizer.rs• L342-373
Resampling and output timing
Spotify audio normally arrives as stereo 44.1 kHz audio, but a system output may require another rate. Spotifast converts the stream only when the output rate differs and keeps conversion state across input chunks.
Sample-rate conversion
The resampler uses a continuous windowed filter. It carries the edge samples and phase from one chunk to the next, so packet boundaries do not create separate conversion starts. Matching input and output rates need no conversion.
The output asks for Spotify's native format first. If the device accepts another rate, the converter preserves pitch and level while producing the rate the device needs.
References: src/resample.rs• L1-9 src/resample.rs• L20-113 src/sink.rs• L597-605 src/sink.rs• L1014-1035
Output timing
The output keeps a small timing margin between decoded audio and the device clock. It can adjust the read rate by a small amount to restore that margin without inserting silence. When a route fails or the queue runs dry, it rebuilds the route or grows the margin within safe limits.
This timing work protects playback from normal differences between Spotify's stream clock and the hardware clock. It does not hide a persistent output failure; the app still reports a fault when recovery cannot continue.
References: src/…/audio.rs• L544-595 src/…/audio.rs• L999-1041 src/…/audio.rs• L1087-1180
Session reads and listening history
Playback uses the signed-in Spotify session for some reads and keeps a private local record of meaningful listening. These two paths support the UI without treating every screen load as a Web API request or treating every skip as a completed play.
Session-backed reads
Session-backed reads use the same streaming session that powers playback. They can read catalogue and playlist data that Spotify's own clients can see, then shape the result for the app. A final refusal becomes a final UI error, while a transport or decode problem can fall back to another source.
This path is useful for data that the Web API does not provide or that should not spend the shared Web API limit. It is separate from the audio sink: a read can fail without stopping an item that is already playing.
References: src/session_reads.rs• L1-4 src/session_reads.rs• L160-194 src/session_reads.rs• L729-783 src/session_reads.rs• L816-840
Listening records
Local listening history counts active playback time for the current item. Pauses and seeks do not add time. A track counts after 30 seconds or after half of a shorter track, with a one-second minimum, and each play is recorded once.
The record is private to the computer and is merged with Spotify's recently played results for the Recent view. A matching Spotify report is shown once rather than twice. Local history is capped and can be cleared from Settings.
References: src/history.rs• L1-7 src/history.rs• L15-32 src/history.rs• L98-119 src/history.rs• L150-205 src/…/settings.rs• L2353-2442
Playback controls
The bottom player bar is the main playback surface. It presents the current item and artwork beside transport controls, progress, volume, device choice, queue, lyrics, and listening activity entry points.
Transport controls
The bar exposes shuffle, previous, play or pause, next, repeat, and a seek slider. It shows loading while a command is being resolved and keeps a preview position while the seek slider is dragged. The committed position becomes the next player command.
The same actions can come from media keys, tray controls, keyboard commands, and desktop media interfaces. They all enter the app's action path, which keeps local and remote targets consistent.
References: src/…/player_bar.rs• L705-941 src/app.rs• L5038-5055 src/app.rs• L5690-5714 src/app.rs• L12759-12808
Volume controls
The bar and shaded equalizer view show one volume control. A drag previews the level and a release commits it. Mute stores the prior useful level so unmute can restore it.
The control is disabled when the active remote device does not accept volume changes from Spotifast. For the local player, volume changes apply to the output path and are also kept in the local playback state.
References: src/…/player_bar.rs• L943-1036 src/…/equalizer.rs• L144-181 src/app.rs• L11200-11271 src/app.rs• L12808-12840
Now-playing presentation
The now-playing area links artwork, title, artist, album or show, save actions, drag-and-drop, and context actions to the current item. Its visualizer uses recent post-equalizer audio and can show a spectrum or waveform behind the controls.
The bar also shows when playback is remote. Its device button opens target selection, while queue and lyrics buttons open related playback surfaces without changing the current item.
References: src/…/player_bar.rs• L123-176 src/…/player_bar.rs• L420-701 src/…/player_bar.rs• L1037-1124 src/vis.rs• L52-65
Playlist controls
The Winamp playlist is a second playback surface for the current item and the upcoming local queue. It supports row selection, double-click playback, queue removal, queue clearing, list loading, and saving the current list as a playlist. It changes only this computer's queue when the active target permits local queue edits.
The skin playlist keeps the current row distinct from queued rows and keeps titles readable when a title uses a right-to-left script. Its mini transport mirrors the main play, seek, previous, next, and stop actions.
References: src/…/playlist.rs• L38-124 src/…/playlist.rs• L275-338 src/…/playlist.rs• L349-501 src/…/playlist.rs• L626-818 src/…/pixel_text.rs• L1-9
Change checklist
When these files or sections are changed, remember to consider these:
- Keep
Playback,LocalState, andNowPlayingchanges aligned so loading, seeking, replay, and remote takeover do not leave stale controls. - Preserve the distinction between volume preview and committed volume. The local output and the Spotify Connect state must not update at different times.
- Keep the signal order stable when changing equalizer, limiter, visualizer, or resampling behavior. The visualizer must remain independent of final output volume.
- Keep output-device identifiers compatible with older saved names and with the device selector.
- Keep the local-history threshold and merge window aligned with the meaning of Spotify's recently played timestamps.
- Keep local command routing separate from remote-device routing when adding a new playback control.
- Keep built-in playback and Soloist status actions aligned with the provider shown in Settings and in the recovery banner.
- Keep queue row positions separate from queue item URIs when changing playlist menus or row playback.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| No system output is available | Local playback reports an error instead of playing, but the app stays usable as a Connect remote. | Open the sink on demand and surface the output error through player state. |
| A selected output disappears | Audio may stop until the route or default output is available again. | Reopen the output and fall back to the system default when the saved device is absent. |
| A track is explicitly replaced while old audio is queued | The old item can be heard in front of the selected item. | Interrupt with a fade, clear the old queue, and wait for the replacement track event. |
| A seek or track change leaves old filter and resampler state active | Audio can contain a transition artifact from the previous signal. | Reset output processing at confirmed decoder transitions. |
| A remote device rejects volume writes | The slider can appear to work while the remote level does not change. | Read the device capability and disable the control when volume is not writable. |
| A session ends during playback | The Connect connection is gone while the current item may still be buffered. | Retain the player state and resume the item when a replacement session connects. |
| Soloist stops or needs pairing again | Local playback cannot resume through that provider until it is repaired or the built-in player is chosen. | Keep the recovery banner visible with retry, reconnect, and built-in-player actions. |
| Playback settings are changed without restarting the built-in engine | The saved choice and the active engine can use different quality or output behavior. | Mark engine settings dirty and require Apply and restart playback. |
| An update is installed while music is playing | Spotifast restarts and local music stops. | Tell the user before restart and offer installation as an explicit action. |
| Playback is skipped before the listening threshold | The item appears in playback but should not count as a completed local play. | Count only active listening time that reaches the track-specific threshold. |
Key files
| File | Why to read it |
|---|---|
| src/player.rs | Defines the local playback state, command contract, Connect session, event folding, and resume behavior. |
| src/sink.rs | Explains selected outputs, queue handoff, fades, device recovery, and output volume. |
| src/eq.rs | Defines local equalizer, preamp, balance, and mono behavior. |
| src/limiter.rs | Shows how boosted or resampled audio is kept within the output ceiling. |
| src/resample.rs | Describes rate conversion across decoder chunks. |
| src/history.rs | Defines when local listening counts and how local and Spotify history merge. |
| src/session_reads.rs | Shows the role and error boundary of reads through the streaming session. |
| src/…/player_bar.rs | Connects the main playback controls and now-playing view to app actions. |
| src/…/equalizer.rs | Connects the equalizer and shaded volume controls to playback settings. |
| src/…/playlist.rs | Connects the skin playlist, queue actions, and mini transport to playback. |
| src/…/soloist.rs | Explains the optional Spotify Soloist setup, status, recovery, and provider switch. |
| src/…/settings.rs | Shows the user-facing playback, equalizer, cache, and provider settings. |
| src/app.rs | Coordinates target selection, command dispatch, optimistic UI state, listening tracking, and playback settings. |