SpeakingWhileMutedRecognition class
The SpeakingWhileMutedRecognition.stream emits state changes when an increase in audio volume
is detected while the user is muted.
-
When the user is not muted or no audio is detected, SpeakingWhileMutedState.isSpeakingWhileMuted remains
false. -
If audio is detected while the user is muted, SpeakingWhileMutedState.isSpeakingWhileMuted becomes
true. -
If no audio is detected for a period of time, or if the user unmutes, the state reverts to
false.
Note:
- Audio detection begins only after the user mutes themselves or is muted by someone else.
- If the user joins a call already muted, audio detection won't start automatically. To enable detection in such cases, use the start method manually.
Example usage:
late StreamSubscription<SpeakingWhileMutedState> _speechSubscription;
late SpeakingWhileMutedRecognition _speakingWhileMutedRecognition;
@override
void initState() {
super.initState();
_speakingWhileMutedRecognition =
SpeakingWhileMutedRecognition(call: widget.call);
_speechSubscription = _speakingWhileMutedRecognition.stream.listen((state) {
final context = this.context;
if (state.isSpeakingWhileMuted && context.mounted) {
final colorTheme = StreamVideoTheme.of(context).colorTheme;
ScaffoldMessenger.maybeOf(context)?.showSnackBar(
SnackBar(
content: const Text('You are speaking while muted'),
behavior: SnackBarBehavior.floating,
backgroundColor: colorTheme.accentPrimary,
),
);
}
});
}
@override
void dispose() {
_speechSubscription.cancel();
_speakingWhileMutedRecognition.dispose();
super.dispose();
}
- Inheritance
-
- Object
- StateNotifier<
SpeakingWhileMutedState> - SpeakingWhileMutedRecognition
Constructors
- SpeakingWhileMutedRecognition({required Call call, AudioRecognition? audioRecognition})
Properties
- call → Call
-
final
- debugState → SpeakingWhileMutedState
-
A development-only way to access
stateoutside ofStateNotifier.no setterinherited - hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
If a listener has been added using
addListenerand hasn't been removed yet.no setterinherited - mounted → bool
-
Whether
disposewas called or not.no setterinherited - onError ↔ ErrorListener?
-
A callback for error reporting if one of the listeners added with
addListenerthrows.getter/setter pairinherited - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- state ↔ SpeakingWhileMutedState
-
The current "state" of this
StateNotifier.getter/setter pairinherited -
stream
→ Stream<
SpeakingWhileMutedState> -
A broadcast stream representation of a
StateNotifier.no setterinherited
Methods
-
addListener(
Listener< SpeakingWhileMutedState> listener, {bool fireImmediately = true}) → RemoveListener -
Subscribes to this object.
inherited
-
dispose(
) → Future< void> -
Frees all the resources associated with this object.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
start(
) → Future< void> - Starts the audio detection.
-
toString(
) → String -
A string representation of this object.
inherited
-
updateShouldNotify(
SpeakingWhileMutedState old, SpeakingWhileMutedState current) → bool -
Whether to notify listeners or not when
statechangesinherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited