Skip to content

feat(playback): Add headphone auto-pause on disconnection and fix iOS core functionality#426

Open
mattsigal wants to merge 1 commit into
Moonfin-Client:mainfrom
mattsigal:feature/headphones-support
Open

feat(playback): Add headphone auto-pause on disconnection and fix iOS core functionality#426
mattsigal wants to merge 1 commit into
Moonfin-Client:mainfrom
mattsigal:feature/headphones-support

Conversation

@mattsigal

Copy link
Copy Markdown
Contributor

The one about EXPERIMENTAL Headphones Support

Summary

This PR adds support for headphone auto-pause when disconnected (e.g., AirPods removal or wired headphone unplug) and fixes media key controls (play/pause) on iOS/iPadOS.

Related Issues

Requested on Discord.

  • Closes #
  • Fixes #
  • Related to #

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Performance improvement
  • UI/UX update
  • Documentation update
  • Build/CI change
  • Other (describe):

Changes Made

  • iOS/iPadOS Headphone Controls Fix (lib/playback/audio_handler.dart): Added MediaAction.play and MediaAction.pause to the systemActions configuration in MoonfinAudioHandler. This allows iOS's MPRemoteCommandCenter to register play/pause handlers so that AirPods, lock screen, and system control center events are handled (bug fix).
  • Headphone Disconnection Auto-Pause (lib/main.dart): Configured a listener on the AudioSession's becomingNoisyEventStream that automatically pauses playback via PlaybackManager.pause().

Platform

  • Android
  • iOS
  • macOS
  • Windows
  • Linux
  • All / Shared code

Testing

  • Tested on emulator / simulator
  • Tested on physical device
  • Manual testing completed
  • Not tested (explain why): As headphone hardware disconnection and iOS remote command center actions require physical device interaction and local testing hardware was unavailable, this PR is submitted as a draft for verification by remote testers and should be tagged as experimental

Test Steps

  1. Play any audio/video on iOS or Android and unplug/disconnect headphones/AirPods. Verify that playback auto-pauses.
  2. Play any media on iOS/iPadOS and verify play/pause buttons work on the Lock Screen, Control Center, and via AirPods force sensors.

Screenshots (if applicable)

N/A

Checklist

  • Code builds successfully
  • Code follows project style and conventions
  • No unnecessary commented-out code
  • No new warnings introduced

… play/pause media controls

- Listen to AudioSession.becomingNoisyEventStream and pause playback when headphones are disconnected/unplugged.
- Add MediaAction.play and MediaAction.pause to systemActions in MoonfinAudioHandler to enable iOS Lock Screen and AirPods Pro media key controls.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant