Skip to content

fix: iOSでオーディオが破棄された時の動作を修正する#1

Open
FujiKinaga wants to merge 5 commits into
masterfrom
fix-audio-focus
Open

fix: iOSでオーディオが破棄された時の動作を修正する#1
FujiKinaga wants to merge 5 commits into
masterfrom
fix-audio-focus

Conversation

@FujiKinaga
Copy link
Copy Markdown

No description provided.

Copilot AI review requested due to automatic review settings May 27, 2025 02:49
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes the behavior when the iOS audio session is torn down by tracking whether the session was activated and only deactivating it if needed.

  • Introduce didActivateAudioSession flag to record when the session is activated
  • Set the flag on activation in onListen and reset it on deactivation in onCancel
  • Guard deactivateAudioSession() with the flag to avoid unintended calls
Comments suppressed due to low confidence (2)

ios/volume_controller/Sources/volume_controller/VolumeListener.swift:12

  • [nitpick] Consider renaming didActivateAudioSession to a boolean-style name like hasActivatedAudioSession to make the intent clearer and align with typical Swift naming conventions.
private var didActivateAudioSession: Bool = false

ios/volume_controller/Sources/volume_controller/VolumeListener.swift:38

  • Add unit tests for onCancel to verify that deactivateAudioSession() is only called when the session was previously activated (and that the flag resets correctly).
public func onCancel(withArguments arguments: Any?) -> FlutterError? {

@@ -9,6 +9,7 @@ public class VolumeListener: NSObject, FlutterStreamHandler {
private var eventSink: FlutterEventSink?
private var isObserving: Bool = false
private let volumeKey: String = "outputVolume"
Copy link

Copilot AI May 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a brief comment above this flag explaining its purpose (e.g., to track whether activateAudioSession() was called) to aid future maintainers.

Suggested change
private let volumeKey: String = "outputVolume"
private let volumeKey: String = "outputVolume"
// Tracks whether the audio session was successfully activated using `activateAudioSession()`.

Copilot uses AI. Check for mistakes.
FujiKinaga and others added 4 commits May 27, 2025 13:48
Changed 'activateAudioSettion' to 'activateAudioSession' across all platform implementations (iOS/Swift and Dart) to fix method name typo.
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.

3 participants