I’m having a similar issue. I can reproduce it on a development version of HA, but I’m having trouble figuring out where any improvements could be made.
Interestingly, if I ask it to play a movie in my library it will do it, but playing an audio file does not seem to work. It just hangs there forever.
There are a few movies where it doesn’t work, but most seem to. I have not found an audio file where it works correctly.
What is very strange to me is that I put a ton of logging debug statements all over the integration, but none of them seem to trigger when I’m browsing the media library through HA or clicking play regardless of if I hit something that works or doesn’t. Either I setup logging wrong, or I’m looking in the incorrect place for the relevant code.
EDIT: Apparently I didn’t put enough logging statements in. I (with the help of deep seek) wrote a script that uses libCST to add a decorator to every function call in the jellyfin integration:
from functools import wraps
import logging
import sys
def debug_decorator(func):
modname = func.__module__
funcname = func.__qualname__
qualname = f'{modname}.{func.__qualname__}'
double_log(f'Decorating {qualname}')
@wraps(func)
def wrapper(*args, **kwargs):
module = sys.modules[modname]
logger = logging.getLogger(module.__name__)
logger.info(f'Call {funcname}')
try:
result = func(*args, **kwargs)
except Exception as ex:
logger.error(f'Error: {ex}')
logger.debug(f'Return from {funcname}')
return result
return wrapper
This decorator will log a statement before and after each call.
I pressed the “play” button, this is what I saw:
2025-03-03 01:26:28.578 DEBUG (MainThread) [homeassistant.components.jellyfin.media_source] Return from JellyfinSource.async_resolve_media
2025-03-03 01:26:28.589 INFO (MainThread) [homeassistant.components.jellyfin.media_source] Call JellyfinSource._get_stream_url
2025-03-03 01:26:28.589 DEBUG (MainThread) [homeassistant.components.jellyfin.media_source] Return from JellyfinSource._get_stream_url
2025-03-03 01:26:28.589 INFO (MainThread) [homeassistant.components.jellyfin.media_source] Call _media_mime_type
2025-03-03 01:26:28.589 DEBUG (MainThread) [homeassistant.components.jellyfin.media_source] Return from _media_mime_type
2025-03-03 01:26:31.076 INFO (MainThread) [homeassistant.components.jellyfin.media_source] Call JellyfinSource.async_resolve_media
2025-03-03 01:26:31.076 DEBUG (MainThread) [homeassistant.components.jellyfin.media_source] Return from JellyfinSource.async_resolve_media
2025-03-03 01:26:31.083 INFO (MainThread) [homeassistant.components.jellyfin.media_source] Call JellyfinSource._get_stream_url
2025-03-03 01:26:31.083 DEBUG (MainThread) [homeassistant.components.jellyfin.media_source] Return from JellyfinSource._get_stream_url
2025-03-03 01:26:31.083 INFO (MainThread) [homeassistant.components.jellyfin.media_source] Call _media_mime_type
2025-03-03 01:26:31.083 DEBUG (MainThread) [homeassistant.components.jellyfin.media_source] Return from _media_mime_type
So, now some of the statements about getting Stream URLs makes more sense. Next step will be to see if there is anything we can do on the HA or jellyfin Python client side to resolve the issue.
EDIT EDIT: I wrote code to dump the values of the args and returns, and saw the streaming url looks something like this:
http://{HOST}:{JELLY_PORT}/Audio/{AUDIO_ID}/universal?UserId={USER_ID}&DeviceId={DEVICE_ID}&MaxStreamingBitrate={BIT_RATE:=140000000}&AudioCodec={CODEC:aac}&api_key={api_key}
And entering that URL gives an error “Error processing request.”, so I assume this is something that either requires better info about metadata such as codec and bitrate, or there is something we can do on the jellyfin side to fix this issue.