Skip to content

Add Volume Mute Toggle Command#6

Merged
YoeriVD merged 10 commits intodevfrom
copilot/add-volume-mute-command
Feb 25, 2026
Merged

Add Volume Mute Toggle Command#6
YoeriVD merged 10 commits intodevfrom
copilot/add-volume-mute-command

Conversation

Copy link

Copilot AI commented Feb 24, 2026

Description

Adds a dedicated mute toggle command for the active player. The command uses the Music Assistant API playerCommandVolumeMute() endpoint when supported, and automatically falls back to volume control for players without native mute support.

Changes:

  • New volume-mute no-view command with toggle logic
  • Added volumeMute(playerId, muted) method to MusicAssistantClient
  • Added supportsMuteControl(player) method to check player mute capability
  • Command entry in package.json with subtitle "Toggle mute on the active player"
  • Test coverage for command and client methods (7 volume-mute tests + 4 supportsMuteControl tests)
  • Updated CHANGELOG.md by adding mute toggle feature to existing unmerged entry

Implementation:

const DEFAULT_UNMUTE_VOLUME = 10;

// Check if player supports native mute control
if (!client.supportsMuteControl(player)) {
  // Fallback: use volume control to simulate mute
  const currentVolume = player.volume_level ?? 0;
  
  if (currentVolume > 0) {
    // Mute by setting volume to 0
    await client.setVolume(selectedPlayerID, 0);
    await showToast({ style: Toast.Style.Success, title: "🔇" });
  } else {
    // Unmute by setting volume to default level
    await client.setVolume(selectedPlayerID, DEFAULT_UNMUTE_VOLUME);
    await showToast({ style: Toast.Style.Success, title: "🔊" });
  }
  return;
}

// Use native mute API for supported players
const mutedBefore = player.volume_muted ?? false;
await client.volumeMute(selectedPlayerID, !mutedBefore);

Toast Feedback:

  • Shows 🔇 when muted
  • Shows 🔊 when unmuted

Player Compatibility:

  • Players with native mute support: Uses playerCommandVolumeMute() API
  • Players without mute support: Falls back to volume control (0 to mute, 10 to unmute)

This ensures the mute toggle command works universally across all Music Assistant players, regardless of their native capabilities.

Screencast

No screencast required - follows established pattern of volume-up/volume-down commands with toast notification feedback.

Checklist

Original prompt

This section details on the original issue you should resolve

<issue_title>Volume Mute Toggle Command</issue_title>
<issue_description>## Description
Add a dedicated "Mute" command to toggle volume mute state on the active player. This separates mute control from the existing volume up/down commands, providing a dedicated quick action for mute functionality.

Priority

P2 - Tier 1

Story Points

3

Effort Estimate

1-2 hours

Acceptance Criteria

  • Command toggles mute state on the active player
  • Shows current mute state (MUTED/UNMUTED) on execution
  • Uses Music Assistant API mute command (investigate playerCommandVolumeMute())
  • Only shown for players that support volume control
  • Handles case where no active player is selected (error message)
  • Works with all player types that support muting
  • Provides visual feedback (toast notification) on state change
  • No-view command (quick action execution)
  • Integrates with existing player selection logic

Implementation Notes

  • Type: No-view Command (quick action)
  • Base Pattern: Similar to src/volume-up.tsx or src/volume-down.tsx
  • API Investigation Needed:
    • Confirm API method for mute toggle (likely playerCommandVolumeMute())
    • Verify parameters and return values
    • Check if separate mute vs unmute methods needed or single toggle
  • Files to Modify:
    • Create src/mute-toggle.tsx (new file) OR src/volume-mute.tsx
    • Update package.json to add command entry for mute-toggle

Technical Notes

  • Investigate whether mute state can be queried from player state
  • Consider volume mute vs player power state (separate concepts)
  • Handle scenarios: no active player, player doesn't support muting, transient API errors

Testing

  • Test with different player types (supports mute)
  • Test toggle functionality (mute → unmute → mute)
  • Test with no active player selected
  • Test with players that don't support volume control
  • Test API error scenarios

Labels

feature, playback-control, tier-1</issue_description>

<agent_instructions>This is about the extension Music Assistant Controls.

Do not modify anything outside that folder and read agents.md in that folder for full context. </agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: YoeriVD <2865793+YoeriVD@users.noreply.github.com>
Copilot AI changed the title [WIP] Add dedicated mute command for volume control Add Volume Mute Toggle Command Feb 24, 2026
@YoeriVD
Copy link
Owner

YoeriVD commented Feb 24, 2026

@copilot The toast should just display the correct icon. No need for extra text in this case.

Co-authored-by: YoeriVD <2865793+YoeriVD@users.noreply.github.com>
Copy link
Author

Copilot AI commented Feb 24, 2026

@copilot The toast should just display the correct icon. No need for extra text in this case.

Updated in 903ba74. The toast now displays only the icon:

  • 🔇 when muted
  • 🔊 when unmuted

Co-authored-by: YoeriVD <2865793+YoeriVD@users.noreply.github.com>
@YoeriVD YoeriVD marked this pull request as ready for review February 24, 2026 18:18
@YoeriVD
Copy link
Owner

YoeriVD commented Feb 24, 2026

@copilot Error: API error: 500 Internal Server Error - Internal server error
at MusicAssistantApi.sendCommand (/Users/yoerivd/.config/raycast/extensions/music-assistant-controls/volume-mute.js:7631:15)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async MusicAssistantApi.playerCommandVolumeMute (/Users/yoerivd/.config/raycast/extensions/music-assistant-controls/volume-mute.js:8134:5)
at async /Users/yoerivd/.config/raycast/extensions/music-assistant-controls/volume-mute.js:8531:44
at async executeApiCommand (/Users/yoerivd/.config/raycast/extensions/music-assistant-controls/volume-mute.js:8363:12)
at async MusicAssistantClient.volumeMute (/Users/yoerivd/.config/raycast/extensions/music-assistant-controls/volume-mute.js:8531:5)
at async main (/Users/yoerivd/.config/raycast/extensions/music-assistant-controls/volume-mute.js:9095:5)

Are you sure mute is supported on all players? 

…layers

Co-authored-by: YoeriVD <2865793+YoeriVD@users.noreply.github.com>
Copy link
Author

Copilot AI commented Feb 24, 2026

@copilot Error: API error: 500 Internal Server Error - Internal server error
at MusicAssistantApi.sendCommand (/Users/yoerivd/.config/raycast/extensions/music-assistant-controls/volume-mute.js:763...

Fixed in 036dac9. The command now checks if the player supports mute control (via the mute_control property) before attempting to mute. Players without mute support will show a friendly error message: "Mute not supported - This player does not support mute control" instead of causing a 500 API error.

@YoeriVD
Copy link
Owner

YoeriVD commented Feb 24, 2026

@copilot if the player does not support mute, just manually set the volume to 0

Co-authored-by: YoeriVD <2865793+YoeriVD@users.noreply.github.com>
Copy link
Author

Copilot AI commented Feb 24, 2026

@copilot if the player does not support mute, just manually set the volume to 0

Updated in 6a8960b. When a player doesn't support mute control, the command now falls back to using volume control:

  • If volume > 0: sets volume to 0 (mute) and shows 🔇
  • If volume = 0: sets volume to 50 (unmute) and shows 🔊

Co-authored-by: YoeriVD <2865793+YoeriVD@users.noreply.github.com>
@YoeriVD
Copy link
Owner

YoeriVD commented Feb 24, 2026

@copilot resolve the conflicts and please use 10 as default unmute volume.

Co-authored-by: YoeriVD <2865793+YoeriVD@users.noreply.github.com>
Copy link
Author

Copilot AI commented Feb 24, 2026

@copilot resolve the conflicts and please use 10 as default unmute volume.

Updated in 40c4344. Changed DEFAULT_UNMUTE_VOLUME from 50 to 10. No merge conflicts were found in the current branch - if there are conflicts with the base branch, they should be visible in the PR interface on GitHub.

@YoeriVD YoeriVD self-requested a review February 25, 2026 09:20
@YoeriVD YoeriVD merged commit 2dac3e8 into dev Feb 25, 2026
@YoeriVD YoeriVD deleted the copilot/add-volume-mute-command branch February 25, 2026 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Volume Mute Toggle Command

2 participants