fix: Release audio focus/session on cancel/pause (Android & iOS)#571
Closed
REU8ER wants to merge 4 commits intollfbandit:masterfrom
Closed
fix: Release audio focus/session on cancel/pause (Android & iOS)#571REU8ER wants to merge 4 commits intollfbandit:masterfrom
REU8ER wants to merge 4 commits intollfbandit:masterfrom
Conversation
…GAIN_TRANSIENT - Add restoreAudioManagerSettings() call in cancel() method to properly release audio focus - Change from AUDIOFOCUS_GAIN to AUDIOFOCUS_GAIN_TRANSIENT for temporary audio focus - This allows other audio apps to automatically resume playback after recording stops Fixes: Audio from external apps (YouTube Music, Spotify, etc.) not resuming after cancel/pause
- Add deactivateAudioSession() helper function - Call deactivateAudioSession() in stop() and pause() methods of both delegates - This properly releases the audio session and notifies other apps to resume Fixes: Audio from external apps (Apple Music, Spotify, etc.) not resuming after stop/pause/cancel
- record_platform_interface: 1.4.0 -> 1.4.1 - record_android: 1.4.5 -> 1.4.6 - record_ios: 1.1.5 -> 1.1.7 - record_macos: 1.1.2 -> 1.1.3 - Update dependencies in all packages to use compatible versions
Update main package version to reflect audio focus/session fixes on Android and iOS platforms.
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.
Description
This PR fixes an issue where audio from external apps (YouTube Music, Spotify, Apple Music, etc.) would not automatically resume after stopping, canceling, or pausing a recording.
Problem
Android
AUDIOFOCUS_GAIN(permanent focus) instead ofAUDIOFOCUS_GAIN_TRANSIENT(temporary focus)cancel()method did not callrestoreAudioManagerSettings()to release audio focusiOS
start()but never deactivated onstop(),pause(), orcancel()Solution
Android Changes
AUDIOFOCUS_GAINtoAUDIOFOCUS_GAIN_TRANSIENTinrequestAudioFocus()restoreAudioManagerSettings()call incancel()methodiOS Changes
deactivateAudioSession()helper functiondeactivateAudioSession()instop()andpause()methods of both delegates.notifyOthersOnDeactivationTesting
Tested on:
Steps to reproduce/verify:
stop(),cancel(), orpause()→ music resumes automatically ✅Modified Files
Android
record_android/android/src/main/kotlin/com/llfbandit/record/record/recorder/AudioRecorder.ktrecord_android/pubspec.yaml(1.4.5 → 1.4.6)record_android/CHANGELOG.mdiOS
record_ios/ios/record_ios/Sources/record_ios/delegate/RecorderFileDelegate.swiftrecord_ios/ios/record_ios/Sources/record_ios/delegate/RecorderStreamDelegate.swiftrecord_ios/ios/record_ios/Sources/record_ios/extension/RecorderSessionExtension.swiftrecord_ios/pubspec.yaml(1.1.5 → 1.1.7)record_ios/CHANGELOG.mdOther
record_platform_interface/pubspec.yaml(1.4.0 → 1.4.1)record_macos/pubspec.yaml(1.1.2 → 1.1.3)record/pubspec.yaml(dependencies updated)Breaking Changes
None. This is a bug fix that improves existing behavior without changing the API.
Checklist
References