mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Add camera play stream support to roku (#64153)
This commit is contained in:
parent
08083f399e
commit
1421797c50
@ -30,6 +30,7 @@ from homeassistant.components.media_player.const import (
|
||||
SUPPORT_VOLUME_STEP,
|
||||
)
|
||||
from homeassistant.components.media_player.errors import BrowseError
|
||||
from homeassistant.components.stream.const import FORMAT_CONTENT_TYPE, HLS_PROVIDER
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ATTR_NAME,
|
||||
@ -79,6 +80,13 @@ ATTRS_TO_LAUNCH_PARAMS = {
|
||||
ATTR_MEDIA_TYPE: "MediaType",
|
||||
}
|
||||
|
||||
PLAY_MEDIA_SUPPORTED_TYPES = (
|
||||
MEDIA_TYPE_APP,
|
||||
MEDIA_TYPE_CHANNEL,
|
||||
MEDIA_TYPE_URL,
|
||||
FORMAT_CONTENT_TYPE[HLS_PROVIDER],
|
||||
)
|
||||
|
||||
ATTRS_TO_PLAY_VIDEO_PARAMS = {
|
||||
ATTR_NAME: "videoName",
|
||||
ATTR_FORMAT: "videoFormat",
|
||||
@ -375,9 +383,9 @@ class RokuMediaPlayer(RokuEntity, MediaPlayerEntity):
|
||||
"""Tune to channel."""
|
||||
extra: dict[str, Any] = kwargs.get(ATTR_MEDIA_EXTRA) or {}
|
||||
|
||||
if media_type not in (MEDIA_TYPE_APP, MEDIA_TYPE_CHANNEL, MEDIA_TYPE_URL):
|
||||
if media_type not in PLAY_MEDIA_SUPPORTED_TYPES:
|
||||
_LOGGER.error(
|
||||
"Invalid media type %s. Only %s, %s and %s are supported",
|
||||
"Invalid media type %s. Only %s, %s, %s, and camera HLS streams are supported",
|
||||
media_type,
|
||||
MEDIA_TYPE_APP,
|
||||
MEDIA_TYPE_CHANNEL,
|
||||
@ -402,6 +410,12 @@ class RokuMediaPlayer(RokuEntity, MediaPlayerEntity):
|
||||
if attr in extra
|
||||
}
|
||||
|
||||
await self.coordinator.roku.play_video(media_id, params)
|
||||
elif media_type == FORMAT_CONTENT_TYPE[HLS_PROVIDER]:
|
||||
params = {
|
||||
"MediaType": "hls",
|
||||
}
|
||||
|
||||
await self.coordinator.roku.play_video(media_id, params)
|
||||
|
||||
await self.coordinator.async_request_refresh()
|
||||
|
@ -48,6 +48,7 @@ from homeassistant.components.roku.const import (
|
||||
DOMAIN,
|
||||
SERVICE_SEARCH,
|
||||
)
|
||||
from homeassistant.components.stream.const import FORMAT_CONTENT_TYPE, HLS_PROVIDER
|
||||
from homeassistant.components.websocket_api.const import TYPE_RESULT
|
||||
from homeassistant.config import async_process_ha_core_config
|
||||
from homeassistant.const import (
|
||||
@ -509,6 +510,25 @@ async def test_services(
|
||||
},
|
||||
)
|
||||
|
||||
with patch("homeassistant.components.roku.coordinator.Roku.play_video") as pv_mock:
|
||||
await hass.services.async_call(
|
||||
MP_DOMAIN,
|
||||
SERVICE_PLAY_MEDIA,
|
||||
{
|
||||
ATTR_ENTITY_ID: MAIN_ENTITY_ID,
|
||||
ATTR_MEDIA_CONTENT_TYPE: FORMAT_CONTENT_TYPE[HLS_PROVIDER],
|
||||
ATTR_MEDIA_CONTENT_ID: "https://awesome.tld/api/hls/api_token/master_playlist.m3u8",
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
pv_mock.assert_called_once_with(
|
||||
"https://awesome.tld/api/hls/api_token/master_playlist.m3u8",
|
||||
{
|
||||
"MediaType": "hls",
|
||||
},
|
||||
)
|
||||
|
||||
with patch("homeassistant.components.roku.coordinator.Roku.remote") as remote_mock:
|
||||
await hass.services.async_call(
|
||||
MP_DOMAIN,
|
||||
|
Loading…
x
Reference in New Issue
Block a user