Skip to content

Commit

Permalink
fix issue 683. (#684)
Browse files Browse the repository at this point in the history
* fix issue 683.

* fix issue #655.
  • Loading branch information
cloudwebrtc authored Jan 13, 2025
1 parent 757bcde commit 20b348c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
23 changes: 9 additions & 14 deletions lib/src/hardware/hardware.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,14 @@ class Hardware {

MediaDevice? selectedVideoInput;

bool? speakerOn;
bool? _speakerOn;

bool? get speakerOn => _speakerOn;

bool _preferSpeakerOutput = false;

bool get preferSpeakerOutput => _preferSpeakerOutput;

Future<List<MediaDevice>> enumerateDevices({String? type}) async {
var infos = await rtc.navigator.mediaDevices.enumerateDevices();
var devices = infos
Expand Down Expand Up @@ -143,21 +147,12 @@ class Hardware {
}
}

bool get preferSpeakerOutput => _preferSpeakerOutput;

bool get canSwitchSpeakerphone =>
(lkPlatformIsMobile()) &&
[AudioTrackState.localOnly, AudioTrackState.localAndRemote]
.contains(audioTrackState);
bool get canSwitchSpeakerphone => lkPlatformIsMobile();

Future<void> setSpeakerphoneOn(bool enable) async {
if (lkPlatformIsMobile()) {
speakerOn = enable;
if (canSwitchSpeakerphone) {
await rtc.Helper.setSpeakerphoneOn(enable);
} else {
logger.warning('Can\'t switch speaker/earpiece');
}
if (canSwitchSpeakerphone) {
_speakerOn = enable;
await rtc.Helper.setSpeakerphoneOn(enable);
} else {
logger.warning('setSpeakerphoneOn only support on iOS/Android');
}
Expand Down
3 changes: 1 addition & 2 deletions lib/src/track/track.dart
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,8 @@ abstract class Track extends DisposableChangeNotifier
logger
.fine('$objectId.disable() disabling ${mediaStreamTrack.objectId}...');
try {
if (_active || !_muted) {
if (_active) {
mediaStreamTrack.enabled = false;
if (!_muted) _muted = true;
}
} catch (_) {
logger.warning(
Expand Down

0 comments on commit 20b348c

Please sign in to comment.