Match muted behavior with JS SDK (#32)
* attempt 1 * implement * clean up * clean up * cleaner code * mute was opposite * fix suggestion * fix local pub muted * update example * update pubs * format
This commit is contained in:
@@ -247,15 +247,16 @@ extension LocalParticipantTrackSourceExt on LocalParticipant {
|
||||
}
|
||||
|
||||
Future<void> setSourceEnabled(TrackSource source, bool enabled) async {
|
||||
final pub = getTrackPublicationBySource(source);
|
||||
logger.fine('setSourceEnabled(source: $source, enabled: $enabled)');
|
||||
final pub = getTrackPublicationBySource(source) as LocalTrackPublication?;
|
||||
if (pub != null) {
|
||||
if (enabled) {
|
||||
pub.muted = false;
|
||||
await pub.unmute();
|
||||
} else {
|
||||
if (source == TrackSource.screenShareVideo) {
|
||||
await unpublishTrack(pub.sid);
|
||||
} else {
|
||||
pub.muted = true;
|
||||
await pub.mute();
|
||||
}
|
||||
}
|
||||
} else if (enabled) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:livekit_client/src/track/track.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import '../events.dart';
|
||||
@@ -8,6 +7,7 @@ import '../logger.dart';
|
||||
import '../managers/event.dart';
|
||||
import '../proto/livekit_models.pb.dart' as lk_models;
|
||||
import '../support/disposable.dart';
|
||||
import '../track/track.dart';
|
||||
import '../track/track_publication.dart';
|
||||
import '../types.dart';
|
||||
import 'remote_participant.dart';
|
||||
@@ -199,6 +199,11 @@ extension ParticipantTrackSourceExt on Participant {
|
||||
true);
|
||||
}
|
||||
|
||||
bool isScreenShareEnabled() {
|
||||
return !(getTrackPublicationBySource(TrackSource.screenShareVideo)?.muted ??
|
||||
true);
|
||||
}
|
||||
|
||||
/// Find a track publication by its [TrackSource]
|
||||
TrackPublication? getTrackPublicationBySource(TrackSource source) {
|
||||
if (source == TrackSource.unknown) return null;
|
||||
|
||||
@@ -98,8 +98,7 @@ class RemoteParticipant extends Participant {
|
||||
}
|
||||
|
||||
await track.start();
|
||||
|
||||
pub.track = track;
|
||||
await pub.updateTrack(track);
|
||||
addTrackPublication(pub);
|
||||
|
||||
[events, roomEvents].emit(TrackSubscribedEvent(
|
||||
|
||||
Reference in New Issue
Block a user