feat: Add 'call' support to improve 2-way audio experience (#2486)
Draws significant inspiration (and direct styling) from https://github.com/dermotduffy/advanced-camera-card/pull/2447 . Thank you @Maudfer ! BREAKING CHANGE: The microphone condition previously bundled two unrelated signals — whether a two-way-audio session was connected and whether the microphone was muted. Connection state is now its own dedicated call condition, and microphone is reserved purely for mute state. Configs are upgraded automatically (the card rewrites affected conditions under overrides, elements, and automations). If you maintain config by hand, convert as follows: If you only used connected: # Before ```yaml condition: microphone connected: true ``` # After ```yaml condition: call call: true ``` If you used both connected and muted — they must be split into two conditions, since they no longer live together: # Before ```yaml condition: microphone connected: true muted: false ``` # After ```yaml condition: and conditions: - condition: call call: true - condition: microphone muted: false ```
This commit is contained in:
committed by
dermotduffy
parent
bb061a1a55
commit
abcba884e5
@@ -26,6 +26,7 @@ interface MicrophoneActionsControllerOptions {
|
||||
export class MicrophoneActionsController {
|
||||
private _options: MicrophoneActionsControllerOptions | null = null;
|
||||
private _selectedCamera: string | null = null;
|
||||
private _callActive = false;
|
||||
private _visibilityObserver: VisibilityObserver;
|
||||
|
||||
constructor() {
|
||||
@@ -38,6 +39,27 @@ export class MicrophoneActionsController {
|
||||
this._options = options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies the controller of the call-active state, acting only on a genuine
|
||||
* transition. The initial state is treated as inactive, so a first-ever
|
||||
* `true` counts -- the call rules apply even when the live view first
|
||||
* appears during an active call.
|
||||
*
|
||||
* Call start unmutes the microphone only if the user opted into
|
||||
* `microphone.auto_unmute: ['call']`.
|
||||
*/
|
||||
public setCallActive(active: boolean): void {
|
||||
if (active === this._callActive) {
|
||||
return;
|
||||
}
|
||||
this._callActive = active;
|
||||
if (active) {
|
||||
this._unmuteIfConfigured('call');
|
||||
} else {
|
||||
this._muteIfConfigured('call');
|
||||
}
|
||||
}
|
||||
|
||||
public setRoot(root: HTMLElement): void {
|
||||
this._visibilityObserver.setRoot(root);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user