Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Unable to switch between earpiece & speaker #603

Closed
rahulraj-idt opened this issue Oct 8, 2024 · 14 comments · Fixed by #604
Closed

[bug] Unable to switch between earpiece & speaker #603

rahulraj-idt opened this issue Oct 8, 2024 · 14 comments · Fixed by #604

Comments

@rahulraj-idt
Copy link

There is a critical issue where the audio is only coming through the speaker. Additionally, Hardware.instance.canSwitchSpeakerphone is always false, and Hardware.instance.setSpeakerphoneOn(false) has no effect on iOS.
Similarly, On Android, setting room.setAudioOutputDevice('earpiece') also has no effect.
This functionality used to work in version 2.1.3

To Reproduce
This issue is easy to reproduce by running the example app and attempting to switch to the earpiece on Android. On iOS, the button to switch to the speaker is disabled.

Expected behavior
Should be able to switch between earpiece & speaker.

Platform information
iOS - 17.6.1, Android - 13

  • Flutter version:
    Flutter 3.24.3
  • Plugin version:
    livekit_client: ^2.2.6
@aytunch
Copy link

aytunch commented Oct 8, 2024

I am having the same issue with speaker usage

@nexowasolutions
Copy link

We are also having same issue with flutter version 3.22.0 and livekit_client: ^2.2.6

@rahulraj-idt
Copy link
Author

Hi @cloudwebrtc Are there any plans to fix this, as it's such a critical issue?

@cloudwebrtc
Copy link
Contributor

Sorry, I just saw this, trying to fix it.

@cloudwebrtc
Copy link
Contributor

@rahulraj-idt fixed it, tested and can switch the handset and speaker correctly.

@rahulraj-idt
Copy link
Author

@cloudwebrtc It fixes the issue on android. But this still doesn't work on iOS.

@rahulraj-idt
Copy link
Author

@cloudwebrtc on iOS, the speaker is always on and Hardware.instance.canSwitchSpeakerphone is always false & await rtc.Helper.setSpeakerphoneOn(true/false) has no effect. Seems a bug with flutter_webrtc

@cloudwebrtc
Copy link
Contributor

ah, okay, let me check it.

@rahulraj-idt
Copy link
Author

Hello @cloudwebrtc
I'm curious to know whether you had an opportunity to check this iOS speaker issue.

@cloudwebrtc
Copy link
Contributor

fixed #617

@furkanKotic
Copy link
Contributor

fixed #617

@cloudwebrtc In the fix here, you set the _preferSpeakerOutput value to true. Now, in the fix here, you changed it to false. Is there a possibility that this is an Airpods problem again? Can you test it?

@cloudwebrtc
Copy link
Contributor

Yes, you are right, so I guess this is the final solution.

  void setSpeakerphoneOn(bool speakerOn) async {
    if (lkPlatformIs(PlatformType.iOS)) {
      if (!Hardware.instance.speakerOn && Hardware.instance.preferSpeakerOutput) {
        await Hardware.instance.setPreferSpeakerOutput(false);
      }
    }
    await Hardware.instance.setSpeakerphoneOn(speakerOn);
  }

https://github.com/livekit/components-flutter/blob/main/lib/src/context/media_device_context.dart#L285-L290

@std-s
Copy link

std-s commented Dec 13, 2024

Hi, your demo still has this problem on iOS.

@cloudwebrtc
Copy link
Contributor

hi @std-s, please try v2.3.4+hotfix.1, I believe the issue has been fixed

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 a pull request may close this issue.

6 participants