fix: Use auto_unmute as input to stream selection for HA (#2562)
- Closes #2479
This commit is contained in:
@@ -13,6 +13,7 @@ import { createRef, ref, type Ref } from 'lit/directives/ref.js';
|
||||
|
||||
import type { Camera } from '../../camera-manager/camera.js';
|
||||
import { LazyLoadController } from '../../components-lib/lazy-load-controller.js';
|
||||
import { isAudioIntendedOnLoad } from '../../components-lib/live/audio-intent.js';
|
||||
import { dispatchLiveErrorEvent } from '../../components-lib/live/utils/dispatch-live-error.js';
|
||||
import { MediaLoadedInfoSinkController } from '../../components-lib/media-loaded-info-sink-controller.js';
|
||||
import type { PartialZoomSettings } from '../../components-lib/zoom/types.js';
|
||||
@@ -335,6 +336,8 @@ export class AdvancedCameraCardLiveProvider extends LitElement implements MediaP
|
||||
.hass=${this.hass}
|
||||
.camera=${this.camera}
|
||||
.targetID=${this.targetID}
|
||||
.preferAudioStream=${this.forceSelected &&
|
||||
isAudioIntendedOnLoad(this.liveConfig?.auto_unmute ?? [])}
|
||||
?controls=${this._getEffectiveBuiltinControls()}
|
||||
@advanced-camera-card:live:error=${(ev: Event) =>
|
||||
this._providerErrorHandler(ev)}
|
||||
|
||||
@@ -9,6 +9,7 @@ import { customElement, property } from 'lit/decorators.js';
|
||||
import { createRef, ref, type Ref } from 'lit/directives/ref.js';
|
||||
|
||||
import type { Camera } from '../../../camera-manager/camera.js';
|
||||
import { HAStreamMuteController } from '../../../components-lib/live/ha-stream-mute-controller.js';
|
||||
import type { HomeAssistant } from '../../../ha/types';
|
||||
|
||||
import '../../../patches/ha-camera-stream';
|
||||
@@ -37,8 +38,20 @@ export class AdvancedCameraCardLiveHA extends LitElement implements MediaPlayer
|
||||
@property({ attribute: true, type: Boolean })
|
||||
public controls = false;
|
||||
|
||||
@property({ attribute: false })
|
||||
public preferAudioStream = false;
|
||||
|
||||
private _playerRef: Ref<MediaPlayerElement> = createRef();
|
||||
|
||||
// Owns the mute state for the underlying ha-camera-stream: it feeds `muted`
|
||||
// (which is surprisingly used by HA to select WebRTC vs HLS streams) and
|
||||
// `outputMute` (the actual player's audio output) into the element, seeded
|
||||
// from the audio intent.
|
||||
private _muteController = new HAStreamMuteController(this, {
|
||||
getCameraEntityID: () => this.camera?.getConfig()?.camera_entity ?? null,
|
||||
getPreferAudioStream: () => this.preferAudioStream,
|
||||
});
|
||||
|
||||
public async getMediaPlayerController(): Promise<MediaPlayerController | null> {
|
||||
await this.updateComplete;
|
||||
return (await this._playerRef.value?.getMediaPlayerController()) ?? null;
|
||||
@@ -56,6 +69,8 @@ export class AdvancedCameraCardLiveHA extends LitElement implements MediaPlayer
|
||||
.stateObj=${cameraEntity ? this.hass.states[cameraEntity] : undefined}
|
||||
.controls=${this.controls}
|
||||
.targetID=${this.targetID}
|
||||
.muted=${this._muteController.getIntendedMute()}
|
||||
.outputMute=${this._muteController.getOutputMute()}
|
||||
>
|
||||
</advanced-camera-card-ha-camera-stream>`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user