Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix support for mpeg dash based radio streams #450

Merged
merged 1 commit into from Aug 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions music_assistant/helpers/audio.py
Expand Up @@ -271,6 +271,13 @@ async def get_stream_details(
streamdetails.loudness = loudness
if not streamdetails.duration:
streamdetails.duration = queue_item.duration
# make sure that ffmpeg handles mpeg dash streams directly
if (
streamdetails.content_type == ContentType.MPEG_DASH
and streamdetails.data
and streamdetails.data.startswith("http")
):
streamdetails.direct = streamdetails.data
# set streamdetails as attribute on the media_item
# this way the app knows what content is playing
queue_item.streamdetails = streamdetails
Expand Down
2 changes: 2 additions & 0 deletions music_assistant/models/enums.py
Expand Up @@ -121,6 +121,7 @@ class ContentType(Enum):
PCM_S32LE = "s32le" # PCM signed 32-bit little-endian
PCM_F32LE = "f32le" # PCM 32-bit floating-point little-endian
PCM_F64LE = "f64le" # PCM 64-bit floating-point little-endian
MPEG_DASH = "dash"
UNKNOWN = "?"

@classmethod
Expand All @@ -141,6 +142,7 @@ def try_parse(cls: "ContentType", string: str) -> "ContentType":
tempstr = tempstr.split("&")[0]
tempstr = tempstr.split(";")[0]
tempstr = tempstr.replace("mp4", "m4a")
tempstr = tempstr.replace("mpd", "dash")
try:
return cls(tempstr)
except ValueError:
Expand Down