livekit / client-sdk-flutter

Flutter Client SDK for LiveKit
https://docs.livekit.io
Apache License 2.0
229 stars 108 forks source link

Windows Communication Detection Caused System Volume to be Lowered Significantly #506

Closed KiriRainCat closed 2 months ago

KiriRainCat commented 2 months ago

Describe the bug When voice chat started, on Windows, the system volume is lowered by 80%. Although, this can be solved by asking the user to manually change the setting, but this wasn't the proper approach.

To Reproduce Publish a microphone track via room.localParticipant?.setMicrophoneEnabled(true);

Expected behavior The Windows' system volume shouldn't be lowered when microphone track is published.

Platform information

KiriRainCat commented 2 months ago

Manually fixed by using the package win32_registry to set the DWORD key UserDuckingPreference to 3 under the path 计算机\HKEY_CURRENT_USER\Software\Microsoft\Multimedia\Audio

const String keyPath = r"Software\Microsoft\Multimedia\Audio";
final RegistryKey key = Registry.openPath(
  RegistryHive.currentUser,
  path: keyPath,
  desiredAccessRights: AccessRights.allAccess,
);

if (key.getValueAsInt("UserDuckingPreference") == 3) return;
key.createValue(const RegistryValue("UserDuckingPreference", RegistryValueType.int32, 3));
key.close();