Skip to content

Commit

Permalink
fix: Fix certain webrtc streams that were not loading correctly (#1766
Browse files Browse the repository at this point in the history
)
  • Loading branch information
dermotduffy authored Dec 16, 2024
1 parent 9f4ddb1 commit 092c050
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/patches/ha-web-rtc-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import { css, CSSResultGroup, html, TemplateResult, unsafeCSS } from 'lit';
import { customElement } from 'lit/decorators.js';
import { query } from 'lit/decorators/query.js';
import { ifDefined } from 'lit/directives/if-defined.js';
import { dispatchLiveErrorEvent } from '../components-lib/live/utils/dispatch-live-error.js';
import { renderMessage } from '../components/message.js';
import liveHAComponentsStyle from '../scss/live-ha-components.scss';
Expand Down Expand Up @@ -111,6 +112,7 @@ customElements.whenDefined('ha-web-rtc-player').then(() => {
.muted=${this.muted}
?playsinline=${this.playsInline}
?controls=${this.controls}
poster=${ifDefined(this.posterUrl)}
@loadedmetadata=${() => {
if (this.controls) {
hideMediaControlsTemporarily(
Expand All @@ -119,23 +121,26 @@ customElements.whenDefined('ha-web-rtc-player').then(() => {
);
}
}}
@loadeddata=${(ev) => {
dispatchMediaLoadedEvent(this, ev, {
player: this,
capabilities: {
supportsPause: true,
hasAudio: mayHaveAudio(this._video),
},
technology: ['webrtc'],
});
}}
@loadeddata=${(ev) => this._loadedDataHandler(ev)}
@volumechange=${() => dispatchMediaVolumeChangeEvent(this)}
@play=${() => dispatchMediaPlayEvent(this)}
@pause=${() => dispatchMediaPauseEvent(this)}
></video>
`;
}

private _loadedDataHandler(ev: Event) {
super._loadedData();
dispatchMediaLoadedEvent(this, ev, {
player: this,
capabilities: {
supportsPause: true,
hasAudio: mayHaveAudio(this._video),
},
technology: ['webrtc'],
});
}

static get styles(): CSSResultGroup {
return [
super.styles,
Expand Down

0 comments on commit 092c050

Please sign in to comment.