Audio mute unmute fixes (#234)
* progress * refresh * Create Podfile.lock * Update Podfile.lock * pub * update deps. * fix tests * dart format . * fix duplicate imports --------- Co-authored-by: cloudwebrtc <[email protected]>
This commit is contained in:
co-authored by
cloudwebrtc
parent
75412779a2
commit
a23eb6332c
@@ -4,12 +4,12 @@ library livekit_client;
|
||||
export 'src/core/room.dart';
|
||||
export 'src/events.dart';
|
||||
export 'src/exceptions.dart';
|
||||
export 'src/extensions.dart' show WidgetsBindingCompatible;
|
||||
export 'src/hardware/hardware.dart';
|
||||
export 'src/livekit.dart';
|
||||
export 'src/managers/event.dart';
|
||||
export 'src/options.dart';
|
||||
export 'src/participant/local.dart';
|
||||
export 'src/participant/local.dart';
|
||||
export 'src/participant/participant.dart';
|
||||
export 'src/participant/remote.dart';
|
||||
export 'src/proto/livekit_models.pb.dart' show TrackType, VideoQuality;
|
||||
@@ -31,4 +31,3 @@ export 'src/types/video_encoding.dart';
|
||||
export 'src/types/video_parameters.dart';
|
||||
export 'src/widgets/screen_select_dialog.dart';
|
||||
export 'src/widgets/video_track_renderer.dart';
|
||||
export 'src/extensions.dart' show WidgetsBindingCompatible;
|
||||
|
||||
@@ -147,6 +147,7 @@ class AudioPublishOptions {
|
||||
|
||||
/// Turn off the audio track when muted, to avoid the microphone
|
||||
/// indicator light on.
|
||||
@Deprecated('Mic indicator will always turn off now when muted.')
|
||||
final bool stopMicTrackOnMute;
|
||||
|
||||
const AudioPublishOptions({
|
||||
|
||||
@@ -25,7 +25,6 @@ import 'participant.dart';
|
||||
/// Represents the current participant in the room. Instance of [LocalParticipant] is automatically
|
||||
/// created after successfully connecting to a [Room] and will be accessible from [Room.localParticipant].
|
||||
class LocalParticipant extends Participant<LocalTrackPublication> {
|
||||
bool stopMicTrackOnMute = false;
|
||||
@internal
|
||||
LocalParticipant({
|
||||
required Room room,
|
||||
@@ -54,8 +53,6 @@ class LocalParticipant extends Participant<LocalTrackPublication> {
|
||||
publishOptions =
|
||||
publishOptions ?? room.roomOptions.defaultAudioPublishOptions;
|
||||
|
||||
stopMicTrackOnMute = publishOptions.stopMicTrackOnMute;
|
||||
|
||||
final trackInfo = await room.engine.addTrack(
|
||||
cid: track.getCid(),
|
||||
name: track.name,
|
||||
@@ -313,24 +310,13 @@ class LocalParticipant extends Participant<LocalTrackPublication> {
|
||||
logger.fine('setSourceEnabled(source: $source, enabled: $enabled)');
|
||||
final publication = getTrackPublicationBySource(source);
|
||||
if (publication != null) {
|
||||
var track = publication.track;
|
||||
var stopOnMute = stopMicTrackOnMute && track is LocalAudioTrack;
|
||||
if (enabled) {
|
||||
await publication.unmute();
|
||||
if (stopOnMute) {
|
||||
await track.restartTrack();
|
||||
await track.onTrackStarted();
|
||||
}
|
||||
} else {
|
||||
if (source == TrackSource.screenShareVideo) {
|
||||
await unpublishTrack(publication.sid);
|
||||
} else {
|
||||
await publication.mute();
|
||||
if (stopOnMute) {
|
||||
await track.sender?.setTrack(null);
|
||||
await track.stop();
|
||||
await track.onTrackStopped();
|
||||
}
|
||||
}
|
||||
}
|
||||
return publication;
|
||||
|
||||
@@ -52,20 +52,6 @@ mixin LocalAudioManagementMixin on LocalTrack, AudioTrack {
|
||||
}
|
||||
return didUpdate;
|
||||
}
|
||||
|
||||
Future<void> onTrackStopped() async {
|
||||
await _trackCounterLock.synchronized(() async {
|
||||
_localTrackCount--;
|
||||
await _onAudioTrackCountDidChange();
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> onTrackStarted() async {
|
||||
await _trackCounterLock.synchronized(() async {
|
||||
_localTrackCount++;
|
||||
await _onAudioTrackCountDidChange();
|
||||
});
|
||||
}
|
||||
}
|
||||
mixin RemoteAudioManagementMixin on RemoteTrack, AudioTrack {
|
||||
/// Start playing audio track. On web platform, create an audio element and
|
||||
|
||||
Reference in New Issue
Block a user