mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 23:36:36 +00:00
Add support for opening camera media source (#11633)
Co-authored-by: Zack Barett <zackbarett@hey.com>
This commit is contained in:
parent
d38a8a317e
commit
830b449006
@ -115,3 +115,11 @@ export const updateCameraPrefs = (
|
|||||||
entity_id: entityId,
|
entity_id: entityId,
|
||||||
...prefs,
|
...prefs,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const CAMERA_MEDIA_SOURCE_PREFIX = "media-source://camera/";
|
||||||
|
|
||||||
|
export const isCameraMediaSource = (mediaContentId: string) =>
|
||||||
|
mediaContentId.startsWith(CAMERA_MEDIA_SOURCE_PREFIX);
|
||||||
|
|
||||||
|
export const getEntityIdFromCameraMediaSource = (mediaContentId: string) =>
|
||||||
|
mediaContentId.substring(CAMERA_MEDIA_SOURCE_PREFIX.length);
|
||||||
|
@ -11,7 +11,7 @@ import {
|
|||||||
} from "lit";
|
} from "lit";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
import { LocalStorage } from "../../common/decorators/local-storage";
|
import { LocalStorage } from "../../common/decorators/local-storage";
|
||||||
import { HASSDomEvent } from "../../common/dom/fire_event";
|
import { fireEvent, HASSDomEvent } from "../../common/dom/fire_event";
|
||||||
import { navigate } from "../../common/navigate";
|
import { navigate } from "../../common/navigate";
|
||||||
import "../../components/ha-menu-button";
|
import "../../components/ha-menu-button";
|
||||||
import "../../components/ha-icon-button";
|
import "../../components/ha-icon-button";
|
||||||
@ -29,6 +29,10 @@ import type { HomeAssistant, Route } from "../../types";
|
|||||||
import "./ha-bar-media-player";
|
import "./ha-bar-media-player";
|
||||||
import { showWebBrowserPlayMediaDialog } from "./show-media-player-dialog";
|
import { showWebBrowserPlayMediaDialog } from "./show-media-player-dialog";
|
||||||
import { showAlertDialog } from "../../dialogs/generic/show-dialog-box";
|
import { showAlertDialog } from "../../dialogs/generic/show-dialog-box";
|
||||||
|
import {
|
||||||
|
getEntityIdFromCameraMediaSource,
|
||||||
|
isCameraMediaSource,
|
||||||
|
} from "../../data/camera";
|
||||||
|
|
||||||
@customElement("ha-panel-media-browser")
|
@customElement("ha-panel-media-browser")
|
||||||
class PanelMediaBrowser extends LitElement {
|
class PanelMediaBrowser extends LitElement {
|
||||||
@ -181,11 +185,23 @@ class PanelMediaBrowser extends LitElement {
|
|||||||
media_content_id: item.media_content_id,
|
media_content_id: item.media_content_id,
|
||||||
media_content_type: item.media_content_type,
|
media_content_type: item.media_content_type,
|
||||||
});
|
});
|
||||||
} else if (item.media_content_type.startsWith("audio/")) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isCameraMediaSource(item.media_content_id)) {
|
||||||
|
fireEvent(this, "hass-more-info", {
|
||||||
|
entityId: getEntityIdFromCameraMediaSource(item.media_content_id),
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.media_content_type.startsWith("audio/")) {
|
||||||
await this.shadowRoot!.querySelector("ha-bar-media-player")!.playItem(
|
await this.shadowRoot!.querySelector("ha-bar-media-player")!.playItem(
|
||||||
item
|
item
|
||||||
);
|
);
|
||||||
} else {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const resolvedUrl: any = await resolveMediaSource(
|
const resolvedUrl: any = await resolveMediaSource(
|
||||||
this.hass,
|
this.hass,
|
||||||
item.media_content_id
|
item.media_content_id
|
||||||
@ -198,7 +214,6 @@ class PanelMediaBrowser extends LitElement {
|
|||||||
can_play: item.can_play,
|
can_play: item.can_play,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
return [
|
return [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user