diff --git a/homeassistant/components/camera/__init__.py b/homeassistant/components/camera/__init__.py index 25505800709284..45c9ff34cd5780 100644 --- a/homeassistant/components/camera/__init__.py +++ b/homeassistant/components/camera/__init__.py @@ -603,6 +603,7 @@ async def ws_camera_stream(hass, connection, msg): fmt=fmt, keepalive=camera_prefs.preload_stream, options=camera.stream_options, + master_playlist=msg.get("master_playlist") is False, ) connection.send_result(msg["id"], {"url": url}) except HomeAssistantError as ex: diff --git a/homeassistant/components/stream/__init__.py b/homeassistant/components/stream/__init__.py index 2b242389ef0103..4e8a21b51a4aaa 100644 --- a/homeassistant/components/stream/__init__.py +++ b/homeassistant/components/stream/__init__.py @@ -41,7 +41,15 @@ @bind_hass -def request_stream(hass, stream_source, *, fmt="hls", keepalive=False, options=None): +def request_stream( + hass, + stream_source, + *, + fmt="hls", + keepalive=False, + options=None, + master_playlist=True, +): """Set up stream with token.""" if DOMAIN not in hass.config.components: raise HomeAssistantError("Stream integration is not set up.") @@ -73,7 +81,9 @@ def request_stream(hass, stream_source, *, fmt="hls", keepalive=False, options=N if not stream.access_token: stream.access_token = secrets.token_hex() stream.start() - return hass.data[DOMAIN][ATTR_ENDPOINTS][fmt].format(stream.access_token) + return hass.data[DOMAIN][ATTR_ENDPOINTS][fmt][ + 0 if master_playlist else 1 + ].format(stream.access_token) except Exception as err: raise HomeAssistantError("Unable to get stream") from err @@ -93,8 +103,8 @@ async def async_setup(hass, config): hass.data[DOMAIN][ATTR_STREAMS] = {} # Setup HLS - hls_endpoint = async_setup_hls(hass) - hass.data[DOMAIN][ATTR_ENDPOINTS]["hls"] = hls_endpoint + hls_endpoints = async_setup_hls(hass) + hass.data[DOMAIN][ATTR_ENDPOINTS]["hls"] = hls_endpoints # Setup Recorder async_setup_recorder(hass) diff --git a/homeassistant/components/stream/hls.py b/homeassistant/components/stream/hls.py index 92801c4807f090..7b4f4015854fea 100644 --- a/homeassistant/components/stream/hls.py +++ b/homeassistant/components/stream/hls.py @@ -18,7 +18,7 @@ def async_setup_hls(hass): hass.http.register_view(HlsSegmentView()) hass.http.register_view(HlsInitView()) hass.http.register_view(HlsMasterPlaylistView()) - return "/api/hls/{}/master_playlist.m3u8" + return ("/api/hls/{}/master_playlist.m3u8", "/api/hls/{}/playlist.m3u8") class HlsMasterPlaylistView(StreamView):