Don't add audio track if webrtc player is muted (#25767)

This commit is contained in:
Paul Bottein
2025-10-14 12:21:59 +02:00
committed by GitHub
parent 2a5d4ac578
commit 938128d1c3
2 changed files with 11 additions and 4 deletions

View File

@@ -86,7 +86,8 @@ export class HaCameraStream extends LitElement {
const streams = this._streams( const streams = this._streams(
this._capabilities?.frontend_stream_types, this._capabilities?.frontend_stream_types,
this._hlsStreams, this._hlsStreams,
this._webRtcStreams this._webRtcStreams,
this.muted
); );
return html`${repeat( return html`${repeat(
streams, streams,
@@ -190,7 +191,8 @@ export class HaCameraStream extends LitElement {
( (
supportedTypes?: StreamType[], supportedTypes?: StreamType[],
hlsStreams?: { hasAudio: boolean; hasVideo: boolean }, hlsStreams?: { hasAudio: boolean; hasVideo: boolean },
webRtcStreams?: { hasAudio: boolean; hasVideo: boolean } webRtcStreams?: { hasAudio: boolean; hasVideo: boolean },
muted?: boolean
): Stream[] => { ): Stream[] => {
if (__DEMO__) { if (__DEMO__) {
return [{ type: MJPEG_STREAM, visible: true }]; return [{ type: MJPEG_STREAM, visible: true }];
@@ -220,9 +222,10 @@ export class HaCameraStream extends LitElement {
if ( if (
hlsStreams.hasVideo && hlsStreams.hasVideo &&
hlsStreams.hasAudio && hlsStreams.hasAudio &&
!webRtcStreams.hasAudio !webRtcStreams.hasAudio &&
!muted
) { ) {
// webRTC stream is missing audio, use HLS // webRTC stream is missing audio and audio is not muted, use HLS
return [{ type: STREAM_TYPE_HLS, visible: true }]; return [{ type: STREAM_TYPE_HLS, visible: true }];
} }
if (webRtcStreams.hasVideo) { if (webRtcStreams.hasVideo) {

View File

@@ -321,6 +321,10 @@ class HaWebRtcPlayer extends LitElement {
if (!this._remoteStream) { if (!this._remoteStream) {
return; return;
} }
// If the track is audio and the player is muted, we do not add it to the stream.
if (event.track.kind === "audio" && this.muted) {
return;
}
this._remoteStream.addTrack(event.track); this._remoteStream.addTrack(event.track);
if (!this.hasUpdated) { if (!this.hasUpdated) {
await this.updateComplete; await this.updateComplete;