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 <duanweiwei1982@gmail.com>
This commit is contained in:
@@ -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