fix(mobile): only take over audio when playback starts #105

Closed
joshuafhiggins wants to merge 1 commits from t3/activate-audio-on-play into main
pull from: t3/activate-audio-on-play
Owner

Opening the app with a saved queue stopped other apps' audio (Spotify, podcasts). #58 called setIsAudioActiveAsync(true) while restoring a paused queue, which activates the iOS audio session with the doNotMix category and interrupts everyone else.

This removes that call. playlist.play() already activates the session on iOS and requests audio focus on Android, so oTunes now takes over audio only when music actually starts. Android was never affected: expo-audio's setIsAudioActiveAsync(true) only flips a flag there, and focus is requested only on play. setAudioModeAsync at mount only sets the category and does not activate anything.

Limitation (iOS): #58 also let the player's volume slider follow the hardware buttons while a restored queue sits paused. SystemVolume reads that through KVO on AVAudioSession.outputVolume, which only fires while our session is active. Activating a mixable session would keep the KVO working, but then we'd have to switch the category before playing, which is a riskier path. So until the first play, the slider picks up the current volume when it mounts and when the app returns to the foreground, but not live while you press the buttons. Android is unchanged: it uses a settings ContentObserver, which doesn't need focus.

Verification

  • pnpm typecheck (mobile) passes.
  • iOS Simulator: with Safari playing an mp3, I cold-started oTunes with a saved queue (Quiet Riot) and Safari kept playing. I couldn't finish the "press play takes over" step because the device host's xcrun started timing out.
  • Android: not run on device (no dev build on the emulator). The behavior is confirmed from the expo-audio source.

Changes made by Claude Opus 5.5 in Claude Code (T3 Code).

🤖 Generated with Claude Code

Opening the app with a saved queue stopped other apps' audio (Spotify, podcasts). #58 called `setIsAudioActiveAsync(true)` while restoring a paused queue, which activates the iOS audio session with the `doNotMix` category and interrupts everyone else. This removes that call. `playlist.play()` already activates the session on iOS and requests audio focus on Android, so oTunes now takes over audio only when music actually starts. Android was never affected: expo-audio's `setIsAudioActiveAsync(true)` only flips a flag there, and focus is requested only on play. `setAudioModeAsync` at mount only sets the category and does not activate anything. **Limitation (iOS):** #58 also let the player's volume slider follow the hardware buttons while a restored queue sits paused. `SystemVolume` reads that through KVO on `AVAudioSession.outputVolume`, which only fires while our session is active. Activating a mixable session would keep the KVO working, but then we'd have to switch the category before playing, which is a riskier path. So until the first play, the slider picks up the current volume when it mounts and when the app returns to the foreground, but not live while you press the buttons. Android is unchanged: it uses a settings `ContentObserver`, which doesn't need focus. **Verification** - `pnpm typecheck` (mobile) passes. - iOS Simulator: with Safari playing an mp3, I cold-started oTunes with a saved queue (Quiet Riot) and Safari kept playing. I couldn't finish the "press play takes over" step because the device host's `xcrun` started timing out. - Android: not run on device (no dev build on the emulator). The behavior is confirmed from the expo-audio source. --- Changes made by Claude Opus 5.5 in Claude Code (T3 Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
joshuafhiggins added 1 commit 2026-11-16 18:54:26 -05:00
Restoring a paused queue activated the iOS audio session, which
stopped other apps' audio on launch. play() already activates it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
joshuafhiggins closed this pull request 2026-11-16 19:03:44 -05:00

Pull request closed

Please reopen this pull request to perform a merge.
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: joshuafhiggins/otunes#105