feat(media_player): BrowseMedia app directory — root lists the options apps map (curated TiviMate/Wholphin/Netflix/YouTube fallback), selection launches via play_media(app) (P4-2c)
This commit is contained in:
1 parent
034cb5c83d
commit
326f02cb59
3 files changed
+252
No files matched your search
@@ -57,6 +57,7 @@ from .const import (
|
||||
CONF_POWER_ENTITY,
|
||||
CONF_RECEIVER_ENTITY,
|
||||
CONF_RECEIVER_INPUT,
|
||||
DEFAULT_APP_DIRECTORY,
|
||||
DOMAIN,
|
||||
PROTOCOL_MEDIA_KEYS,
|
||||
PROTOCOL_REMOTE_KEYS,
|
||||
@@ -85,6 +86,7 @@ _BASE_FEATURES = (
|
||||
| MediaPlayerEntityFeature.VOLUME_STEP
|
||||
| MediaPlayerEntityFeature.VOLUME_MUTE
|
||||
| MediaPlayerEntityFeature.PLAY_MEDIA
|
||||
| MediaPlayerEntityFeature.BROWSE_MEDIA
|
||||
)
|
||||
|
||||
_PLAYBACK_FEATURES = (
|
||||
@@ -866,6 +868,37 @@ class NvidiaShieldMediaPlayer(MediaPlayerEntity):
|
||||
return False
|
||||
return await self._manager.bring_to_foreground(package)
|
||||
|
||||
# ── BrowseMedia app directory (P4-2c) ──
|
||||
|
||||
async def async_browse_media(self, media_content_type=None, media_content_id=None):
|
||||
"""Root lists the apps map (or the curated default) → play_media(app)."""
|
||||
from homeassistant.components.media_player import (
|
||||
BrowseMediaSource,
|
||||
MediaClass,
|
||||
)
|
||||
|
||||
app_map = self._entry.options.get(CONF_APP_NAME_MAP) or DEFAULT_APP_DIRECTORY
|
||||
children = [
|
||||
BrowseMediaSource(
|
||||
title=name,
|
||||
media_class=MediaClass.APP,
|
||||
media_content_type="app",
|
||||
media_content_id=pkg,
|
||||
can_play=True,
|
||||
can_expand=False,
|
||||
)
|
||||
for pkg, name in app_map.items()
|
||||
]
|
||||
return BrowseMediaSource(
|
||||
title="Apps",
|
||||
media_class=MediaClass.DIRECTORY,
|
||||
media_content_type="apps",
|
||||
media_content_id="apps",
|
||||
can_play=False,
|
||||
can_expand=True,
|
||||
children=children,
|
||||
)
|
||||
|
||||
# ── play_media (§7): channel digits, app/url launch ──
|
||||
|
||||
async def async_play_media(self, media_type: str, media_id: str) -> None:
|
||||
|
||||
Reference in new issue
Block a user