Refactor viewer to support other viewer players.

This commit is contained in:
Dermot Duffy
2023-03-18 13:56:55 -07:00
parent 5a48951874
commit 712713f60c
7 changed files with 285 additions and 290 deletions
+15
View File
@@ -348,3 +348,18 @@ export const isCardInPanel = (card: HTMLElement): boolean => {
parent.host.tagName === 'HUI-PANEL-VIEW'
);
};
/**
* Ensure URLs use the correct HA URL (relevant for Chromecast where the default
* location will be the Chromecast receiver, not HA).
* @param url The media URL
*/
export const canonicalizeHAURL = (
hass: ExtendedHomeAssistant,
url?: string,
): string | null => {
if (hass && url && url.startsWith('/')) {
return hass.hassUrl(url);
}
return url ?? null;
};