Skip to content

Conversation

@unlox775-code-dot-org
Copy link

Summary

This PR adds automatic media pause/resume functionality for macOS users during recording sessions. When enabled, Whispering will automatically pause Apple Music and Spotify when starting a recording and resume them when the recording stops or is canceled.

Type of Change

  • feat: New feature
  • fix: Bug fix
  • docs: Documentation update
  • refactor: Code refactoring (no functional changes)
  • perf: Performance improvement
  • test: Test additions or changes
  • chore: Maintenance tasks
  • style: Code style changes

Changes Made

This implementation adds a macOS-only feature that automatically pauses active media (Apple Music and Spotify) when starting a recording and resumes them when recording stops or is canceled.

Key Components Added:

  1. Settings Integration: Added sound.autoPauseMediaDuringRecording setting (default: true) with macOS-only UI toggle in Sound Settings
  2. Tauri Commands: New Rust commands for media control:
    • macos_pause_active_media: Detects and pauses currently playing Music/Spotify apps
    • macos_resume_media: Resumes previously paused apps
  3. Frontend Integration: Media control module with lifecycle hooks for manual and VAD recording flows
  4. Platform Detection: Feature is hidden on non-macOS platforms and disabled in web mode

Files Modified:

  • apps/whispering/src-tauri/src/lib.rs - Added Tauri command registration
  • apps/whispering/src-tauri/src/macos_media.rs - New macOS media control implementation using AppleScript
  • apps/whispering/src/lib/query/commands.ts - Added media control commands
  • apps/whispering/src/lib/query/index.ts - Exported media commands
  • apps/whispering/src/lib/query/media.ts - New media control module with pause/resume logic
  • apps/whispering/src/lib/settings/settings.ts - Added auto-pause setting with default value
  • apps/whispering/src/routes/(config)/settings/+page.svelte - Added Sound settings navigation
  • apps/whispering/src/routes/(config)/settings/sound/+page.svelte - Added macOS-only toggle for auto-pause feature

Testing

Desktop App Testing

  • Tested on macOS
  • Tested on Windows
  • Tested on Linux
  • Not applicable (web-only change)

General Testing

  • Tested with multiple API providers (if applicable)
  • Verified no API keys are exposed in logs or storage
  • Checked for console errors
  • Tested on different screen sizes (if UI change)

Feature-Specific Testing

  • Music playing → start recording → pauses; stop → resumes
  • Spotify playing → start recording → pauses; stop → resumes
  • Both Music and Spotify playing → both paused/resumed
  • Neither playing → no-op (no errors)
  • Cancel mid-recording → resumes previously paused apps
  • Setting disabled → no pause/resume behavior
  • Non-macOS → option hidden in UI; no functionality changes

Checklist

  • My code follows the project's coding standards (see CONTRIBUTING.md)
  • I've used type instead of interface in TypeScript
  • I've used absolute imports where applicable
  • I've tested my changes thoroughly
  • I've added/updated tests for my changes (if applicable)
  • My changes don't break existing functionality
  • I've updated documentation (if needed)

Screenshots/Recordings

The feature adds a new toggle in Sound Settings (macOS only):

  • "Auto-pause media during recording" with description: "Pauses Apple Music and Spotify during recording. macOS may ask for permission to control these apps on first use."
Screenshot 2025-10-22 at 2 45 48 PM

Additional Notes

Implementation Details

  • Uses AppleScript via osascript to control Music and Spotify apps
  • Best-effort approach: failures don't block recording functionality
  • Only supports Apple Music and Spotify (browser players not handled)
  • macOS may prompt for accessibility permissions on first use

Future Considerations

  • Windows/Linux support could be added via platform-specific media key events
  • Browser media players could be supported via Media Session API or media key events
  • Could be extended to support additional media apps beyond Music/Spotify

Known Limitations

  • Only works with Apple Music and Spotify desktop apps
  • Requires macOS accessibility permissions
  • Browser-based media players are not controlled
  • No Windows/Linux support in this version

@unlox775-code-dot-org unlox775-code-dot-org changed the title Dave auto pause resume media feat(macos): add auto-pause media during recording Oct 22, 2025
@unlox775-code-dot-org unlox775-code-dot-org marked this pull request as ready for review December 5, 2025 02:13
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.

1 participant