Skip to content

Commit

Permalink
Reintroduce ha-hls-player url property
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanjx committed Nov 18, 2024
1 parent 1f5f6c5 commit 0621e75
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/components/ha-hls-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class HaHLSPlayer extends LitElement {

@property() public entityid?: string;

@property() public url?: string;

@property({ attribute: "poster-url" }) public posterUrl?: string;

@property({ type: Boolean, attribute: "controls" })
Expand Down Expand Up @@ -94,14 +96,27 @@ class HaHLSPlayer extends LitElement {
super.updated(changedProps);

const entityChanged = changedProps.has("entityid");
if (entityChanged) {
this._getStreamUrlFromEntityId();
}

if (!entityChanged) {
return;
const urlChanged = changedProps.has("url");
if (urlChanged) {
this._cleanUp();
this._resetError();
try {
this._startHls();
} catch (err: any) {
// Fails if we were unable to get a stream
// eslint-disable-next-line
console.error(err);

fireEvent(this, "streams", { hasAudio: false, hasVideo: false });
}
}
this._getStreamUrl();
}

private async _getStreamUrl(): Promise<void> {
private async _getStreamUrlFromEntityId(): Promise<void> {
this._cleanUp();
this._resetError();

Expand Down

0 comments on commit 0621e75

Please sign in to comment.