# if duration is None (e.g. radio stream) = 48 hours
FALLBACK_DURATION = 172800
+
+# Name of the environment-variable to override base_url
+BASE_URL_OVERRIDE_ENVNAME = "MASS_BASE_URL"
import asyncio
import gc
+import os
import urllib.parse
from time import time
from types import CoroutineType
from aiohttp import web
-from music_assistant.constants import FALLBACK_DURATION, SILENCE_FILE
+from music_assistant.constants import (
+ BASE_URL_OVERRIDE_ENVNAME,
+ FALLBACK_DURATION,
+ SILENCE_FILE,
+)
from music_assistant.helpers.audio import (
check_audio_support,
crossfade_pcm_parts,
@property
def base_url(self) -> str:
"""Return the base url for the stream engine."""
+
+ if BASE_URL_OVERRIDE_ENVNAME in os.environ:
+ # This is a purpously undocumented feature to override the automatic
+ # generated base_url used by the streaming-devices.
+ # If you need this, you know it, but you should probably try to not set it!
+ # Also see https://github.com/music-assistant/hass-music-assistant/issues/802
+ # and https://github.com/music-assistant/hass-music-assistant/discussions/794#discussioncomment-3331209
+ return os.environ[BASE_URL_OVERRIDE_ENVNAME]
+
return f"http://{self._ip}:{self._port}"
def get_stream_url(