Repository navigation
Keep volume and mute across reloads and disconnects - #215
Merged
Merged
Conversation
Volume started at 100 and unmuted after every reload and every disconnect, whatever the user or server had set.
With hardware volume, a change made on the device reached the server only with the next periodic state update, up to 5 seconds later.
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the SDK volume and mute persistence changes.
No open issues 🎉
What changed in this PR
This PR moves volume and mute persistence into the SDK, preserving both settings across reloads and disconnects. It also documents how hardware-volume integrations can report device changes immediately.
Changes:
- Add storage-backed volume and mute restoration, and preserve both during disconnect resets.
- Simplify the sample player to rely on SDK persistence.
- Update hardware-volume guidance and tests for persistence and disconnect behavior.
| File | Description |
|---|---|
tests/unit/state-manager.test.ts |
Remove obsolete volume and mute reset expectations. |
tests/unit/scheduler.test.ts |
Remove the obsolete gain-reset test. |
tests/unit/core.test.ts |
Cover persistence, disconnect preservation, and hardware-volume reporting. |
tests/e2e/sendspin-core.e2e.test.ts |
Expect volume and mute to survive disconnects. |
src/types.ts |
Document persisted settings and hardware-volume reporting. |
src/index.ts |
Clarify hardware-volume behavior in setter comments. |
src/core/volume-store.ts |
Add storage helpers for volume and mute. |
src/core/state-manager.ts |
Restore and save settings, preserving them during resets. |
src/core/core.ts |
Connect the volume store to state management. |
src/audio/scheduler.ts |
Stop refreshing gain when stopping playback. |
README.md |
Explain persistence and hardware-volume integration. |
public/app.js |
Remove redundant sample-level persistence and restoration. |
index.html |
Align the initial volume display with the SDK default. |
Review effort: Balanced
33 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this implement/fix?
The player started at volume 100 and unmuted after every reload and every
disconnect(), whatever the user or the server had set.Volume and mute are now saved through
storage, like the output delay, and restored when the player is created.SendspinPlayeruses localStorage when nostorageis passed, so web apps that never set it now keep a muted player muted after a reload.With
useHardwareVolume, a volume change made on the device only reached the server with the next periodic state update, up to 5 seconds later. The docs now say to callsetVolumeandsetMutedwhen the device volume changes, which reports it right away.Related issue or spec PR (if applicable):
Types of changes
bugfixnew-featureenhancementbreaking-changerefactordocumentationmaintenancecidependencies