mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Show proper media title in media bar (split URI) (#14464)
This commit is contained in:
parent
f0127511b0
commit
076ddb71b6
@ -405,7 +405,13 @@ export const cleanupMediaTitle = (title?: string): string | undefined => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const index = title.indexOf("?authSig=");
|
const index = title.indexOf("?authSig=");
|
||||||
return index > 0 ? title.slice(0, index) : title;
|
let cleanTitle = index > 0 ? title.slice(0, index) : title;
|
||||||
|
|
||||||
|
if (cleanTitle.startsWith("http")) {
|
||||||
|
cleanTitle = decodeURIComponent(cleanTitle.split("/").pop()!);
|
||||||
|
}
|
||||||
|
|
||||||
|
return cleanTitle;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -212,7 +212,7 @@ export class BarMediaPlayer extends SubscribeMixin(LitElement) {
|
|||||||
const mediaDescription = computeMediaDescription(stateObj);
|
const mediaDescription = computeMediaDescription(stateObj);
|
||||||
const mediaDuration = formatMediaTime(stateObj.attributes.media_duration);
|
const mediaDuration = formatMediaTime(stateObj.attributes.media_duration);
|
||||||
const mediaTitleClean = cleanupMediaTitle(
|
const mediaTitleClean = cleanupMediaTitle(
|
||||||
stateObj.attributes.media_title || ""
|
stateObj.attributes.media_title || stateObj.attributes.media_content_id
|
||||||
);
|
);
|
||||||
const mediaArt =
|
const mediaArt =
|
||||||
stateObj.attributes.entity_picture_local ||
|
stateObj.attributes.entity_picture_local ||
|
||||||
@ -232,7 +232,6 @@ export class BarMediaPlayer extends SubscribeMixin(LitElement) {
|
|||||||
<hui-marquee
|
<hui-marquee
|
||||||
.text=${mediaTitleClean ||
|
.text=${mediaTitleClean ||
|
||||||
mediaDescription ||
|
mediaDescription ||
|
||||||
cleanupMediaTitle(stateObj.attributes.media_content_id) ||
|
|
||||||
(stateObj.state !== "playing" && stateObj.state !== "on"
|
(stateObj.state !== "playing" && stateObj.state !== "on"
|
||||||
? this.hass.localize(`ui.card.media_player.nothing_playing`)
|
? this.hass.localize(`ui.card.media_player.nothing_playing`)
|
||||||
: "")}
|
: "")}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user