Skip to content

Commit 2d53037

Browse files
authored
add trackmuted to roomcontext listener (#16)
* add trackmuted to roomcontext listener * remove unnecessary track muted listener
1 parent eeb4505 commit 2d53037

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

lib/src/context/room_context.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,16 @@ class RoomContext extends ChangeNotifier with ChatContextMixin {
134134
Debug.event(
135135
'RoomContext: LocalTrackUnpublishedEvent track = ${event.publication.sid}');
136136
_buildParticipants();
137+
})
138+
..on<TrackMutedEvent>((event) {
139+
Debug.event(
140+
'RoomContext: TrackMutedEvent $roomName participant = ${event.participant.identity} track = ${event.publication.sid}');
141+
_buildParticipants();
142+
})
143+
..on<TrackUnmutedEvent>((event) {
144+
Debug.event(
145+
'RoomContext: TrackUnmutedEvent $roomName participant = ${event.participant.identity} track = ${event.publication.sid}');
146+
_buildParticipants();
137147
});
138148

139149
if (connect && url != null && token != null) {

lib/src/ui/widgets/track/audio_visualizer_widget.dart

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -92,22 +92,13 @@ class _SoundWaveformWidgetState extends State<SoundWaveformWidget>
9292

9393
void _startVisualizer(AudioTrack? track) async {
9494
_listener = track?.createListener();
95-
_listener
96-
?..on<AudioVisualizerEvent>((e) {
97-
if (mounted) {
98-
setState(() {
99-
samples =
100-
e.event.map((e) => ((e as num) * 100).toDouble()).toList();
101-
});
102-
}
103-
})
104-
..on<TrackMutedEvent>((e) {
105-
if (mounted) {
106-
setState(() {
107-
samples = List.filled(samples.length, 0);
108-
});
109-
}
110-
});
95+
_listener?.on<AudioVisualizerEvent>((e) {
96+
if (mounted) {
97+
setState(() {
98+
samples = e.event.map((e) => ((e as num) * 100).toDouble()).toList();
99+
});
100+
}
101+
});
111102
}
112103

113104
void _stopVisualizer() async {

0 commit comments

Comments
 (0)