music-assistant / hass-music-assistant

Turn your Home Assistant instance into a jukebox, hassle free streaming of your favorite media to Home Assistant media players.
Apache License 2.0
1.37k stars 52 forks source link

Kodi as UPnP/DLNA server #1208

Closed gost4711 closed 1 year ago

gost4711 commented 1 year ago

What version of Music Assistant has the issue?

2.0.0b29

The problem

hi, With version 1... I always used KODI as a player. With the 2.... version, Kodi is recognized as a DLNA server, but playback does not work. Sorry, but I don't have any more information. Thanks GOst4711

How to reproduce

I start with PLAY and the button changes to PAUSE and after a short time the play button is visible again The egg timer runs briefly in Kodi.

Relevant log output

No response

Additional information

No response

What version of Home Assistant Core are your running

2023.2.2

What type of installation are you running?

Home Assistant OS

On what type of hardware are you running?

Generic x86-64 (e.g. Intel NUC)

erkr commented 1 year ago

DLNA is not a rock solid standard. So you can try to change some of the DLNA player settings to see if they fix your issue:

gost4711 commented 1 year ago

It's a shame because MA 2 is now useless to me. My speakers need to be connected with bluetooth and I use KODI for that. Here is the LOG

2023-04-26 19:46:59 DEBUG music_assistant.providers.dlna -- DLNA discovery started... 2023-04-26 19:46:59 DEBUG music_assistant.providers.dlna -- Ignoring disabled player: uuid:08f0d182-0096-1000-bf66-90f1aac9d5ca 2023-04-26 19:46:59 DEBUG music_assistant.websocket_api -- [140417068596304] Handling command config/players 2023-04-26 19:47:04 DEBUG music_assistant.server.controllers.config -- Saved data to persistent storage 2023-04-26 19:47:05 DEBUG music_assistant.websocket_api -- [140417068596304] Handling command music/radios 2023-04-26 19:47:10 DEBUG music_assistant.websocket_api -- [140417068596304] Handling command players/queue/play_media 2023-04-26 19:47:10 DEBUG music_assistant.event -- queue_items_updated uuid:98a79e38-fb1d-30b7-7afc-60b57b9e5bde 2023-04-26 19:47:10 DEBUG music_assistant.event -- queue_updated uuid:98a79e38-fb1d-30b7-7afc-60b57b9e5bde 2023-04-26 19:47:10 DEBUG music_assistant.event -- queue_updated uuid:98a79e38-fb1d-30b7-7afc-60b57b9e5bde 2023-04-26 19:47:10 DEBUG music_assistant.event -- player_updated uuid:98a79e38-fb1d-30b7-7afc-60b57b9e5bde 2023-04-26 19:47:11 DEBUG music_assistant.audio -- start media stream for: tunein://radio/s6634 2023-04-26 19:47:11 DEBUG music_assistant.audio -- writer started for tunein://radio/s6634 2023-04-26 19:47:11 DEBUG music_assistant.providers.dlna -- Received event for Player Kodi (DLNA-Linx-Mint): <UpnpService(urn:upnp-org:serviceId:AVTransport, uuid:98a79e38-fb1d-30b7-7afc-60b57b9e5bde)> 2023-04-26 19:47:11 DEBUG music_assistant.event -- queue_updated uuid:98a79e38-fb1d-30b7-7afc-60b57b9e5bde 2023-04-26 19:47:11 DEBUG music_assistant.event -- player_updated uuid:98a79e38-fb1d-30b7-7afc-60b57b9e5bde 2023-04-26 19:47:11 DEBUG music_assistant.providers.dlna -- Received event for Player Kodi (DLNA-Linx-Mint): <UpnpService(urn:upnp-org:serviceId:AVTransport, uuid:98a79e38-fb1d-30b7-7afc-60b57b9e5bde)> 2023-04-26 19:47:11 DEBUG music_assistant.streams -- Got HEAD request to /stream/uuid:98a79e38-fb1d-30b7-7afc-60b57b9e5bde/d33a733d2a4047b9815d4c403d5c1e4e/Nmf5QJutGwMgtm5jp6vrTT.mp3 from 10.0.0.36 headers: <CIMultiDictProxy('Host': '10.0.0.90:8095', 'User-Agent': 'Kodi/20.1 (X11; Linux x86_64) Linux Mint/21.1 App_Bitness/64 Version/20.1-(20.1.0)-Git:20230312-289ec664e3', 'Accept': '/', 'Accept-Encoding': 'deflate, gzip, br, zstd', 'Accept-Charset': 'UTF-8,;q=0.8')> 2023-04-26 19:47:11 DEBUG music_assistant.streams -- Got GET request to /stream/uuid:98a79e38-fb1d-30b7-7afc-60b57b9e5bde/d33a733d2a4047b9815d4c403d5c1e4e/Nmf5QJutGwMgtm5jp6vrTT.mp3 from 10.0.0.36 headers: <CIMultiDictProxy('Host': '10.0.0.90:8095', 'Range': 'bytes=0-', 'User-Agent': 'Kodi/20.1 (X11; Linux x86_64) Linux Mint/21.1 App_Bitness/64 Version/20.1-(20.1.0)-Git:20230312-289ec664e3', 'Accept': '/', 'Accept-Encoding': 'deflate, gzip, br, zstd', 'Accept-Charset': 'UTF-8,;q=0.8')> 2023-04-26 19:47:11 DEBUG music_assistant.streams -- Start serving audio stream Nmf5QJutGwMgtm5jp6vrTT to Kodi (DLNA-Linx-Mint) 2023-04-26 19:47:11 DEBUG music_assistant.streams -- Got HEAD request to /stream/uuid:98a79e38-fb1d-30b7-7afc-60b57b9e5bde/d33a733d2a4047b9815d4c403d5c1e4e/Nmf5QJutGwMgtm5jp6vrTT.mp3 from 10.0.0.36 headers: <CIMultiDictProxy('Host': '10.0.0.90:8095', 'User-Agent': 'Kodi/20.1 (X11; Linux x86_64) Linux Mint/21.1 App_Bitness/64 Version/20.1-(20.1.0)-Git:20230312-289ec664e3', 'Accept': '/', 'Accept-Encoding': 'deflate, gzip, br, zstd', 'Accept-Charset': 'UTF-8,;q=0.8')> 2023-04-26 19:47:11 DEBUG music_assistant.providers.dlna -- Received event for Player Kodi (DLNA-Linx-Mint): <UpnpService(urn:upnp-org:serviceId:AVTransport, uuid:98a79e38-fb1d-30b7-7afc-60b57b9e5bde)> 2023-04-26 19:47:11 DEBUG music_assistant.providers.dlna -- Received event for Player Kodi (DLNA-Linx-Mint): <UpnpService(urn:upnp-org:serviceId:AVTransport, uuid:98a79e38-fb1d-30b7-7afc-60b57b9e5bde)> 2023-04-26 19:47:11 DEBUG music_assistant.providers.dlna -- Received event for Player Kodi (DLNA-Linx-Mint): <UpnpService(urn:upnp-org:serviceId:AVTransport, uuid:98a79e38-fb1d-30b7-7afc-60b57b9e5bde)> 2023-04-26 19:47:11 DEBUG music_assistant.event -- queue_updated uuid:98a79e38-fb1d-30b7-7afc-60b57b9e5bde 2023-04-26 19:47:11 DEBUG music_assistant.event -- player_updated uuid:98a79e38-fb1d-30b7-7afc-60b57b9e5bde 2023-04-26 19:47:11 DEBUG music_assistant.providers.dlna -- Received event for Player Kodi (DLNA-Linx-Mint): <UpnpService(urn:upnp-org:serviceId:AVTransport, uuid:98a79e38-fb1d-30b7-7afc-60b57b9e5bde)> 2023-04-26 19:47:11 DEBUG music_assistant.audio -- Start streaming radio with ICY metadata from url https://mdr-284320-0.sslcast.mdr.de/mdr/284320/0/mp3/high/stream.mp3?ar-distributor=f0a1 2023-04-26 19:47:11 DEBUG music_assistant.providers.dlna -- Received event for Player Kodi (DLNA-Linx-Mint): <UpnpService(urn:upnp-org:serviceId:AVTransport, uuid:98a79e38-fb1d-30b7-7afc-60b57b9e5bde)> 2023-04-26 19:47:11 DEBUG music_assistant.providers.dlna -- Received event for Player Kodi (DLNA-Linx-Mint): <UpnpService(urn:upnp-org:serviceId:AVTransport, uuid:98a79e38-fb1d-30b7-7afc-60b57b9e5bde)> Guessed Channel Layout for Input Stream #0.0 : stereo 2023-04-26 19:47:12 DEBUG music_assistant.streams -- Got GET request to /stream/uuid:98a79e38-fb1d-30b7-7afc-60b57b9e5bde/d33a733d2a4047b9815d4c403d5c1e4e/Nmf5QJutGwMgtm5jp6vrTT.mp3 from 10.0.0.36 headers: <CIMultiDictProxy('Host': '10.0.0.90:8095', 'Range': 'bytes=0-', 'User-Agent': 'Kodi/20.1 (X11; Linux x86_64) Linux Mint/21.1 App_Bitness/64 Version/20.1-(20.1.0)-Git:20230312-289ec664e3', 'Accept': '/', 'Accept-Encoding': 'deflate, gzip, br, zstd', 'Accept-Charset': 'UTF-8,;q=0.8')> 2023-04-26 19:47:12 ERROR music_assistant.streams -- Player Kodi (DLNA-Linx-Mint) is making multiple requests for the same stream, please create an issue report on the Music Assistant issue tracker. 2023-04-26 19:47:12 DEBUG music_assistant.streams -- Got GET request to /stream/uuid:98a79e38-fb1d-30b7-7afc-60b57b9e5bde/d33a733d2a4047b9815d4c403d5c1e4e/Nmf5QJutGwMgtm5jp6vrTT.mp3 from 10.0.0.36 headers: <CIMultiDictProxy('Host': '10.0.0.90:8095', 'Range': 'bytes=0-', 'User-Agent': 'Kodi/20.1 (X11; Linux x86_64) Linux Mint/21.1 App_Bitness/64 Version/20.1-(20.1.0)-Git:20230312-289ec664e3', 'Accept': '/', 'Accept-Encoding': 'deflate, gzip, br, zstd', 'Accept-Charset': 'UTF-8,;q=0.8', 'Icy-MetaData': '1')> 2023-04-26 19:47:12 ERROR music_assistant.streams -- Player Kodi (DLNA-Linx-Mint) is making multiple requests for the same stream, please create an issue report on the Music Assistant issue tracker. 2023-04-26 19:47:12 DEBUG music_assistant.streams -- Got HEAD request to /stream/uuid:98a79e38-fb1d-30b7-7afc-60b57b9e5bde/d33a733d2a4047b9815d4c403d5c1e4e/Nmf5QJutGwMgtm5jp6vrTT.mp3 from 10.0.0.36 headers: <CIMultiDictProxy('Host': '10.0.0.90:8095', 'User-Agent': 'Kodi/20.1 (X11; Linux x86_64) Linux Mint/21.1 App_Bitness/64 Version/20.1-(20.1.0)-Git:20230312-289ec664e3', 'Accept': '/', 'Accept-Encoding': 'deflate, gzip, br, zstd', 'Accept-Charset': 'UTF-8,;q=0.8')> 2023-04-26 19:47:13 DEBUG music_assistant.providers.dlna -- Received event for Player Kodi (DLNA-Linx-Mint): <UpnpService(urn:upnp-org:serviceId:AVTransport, uuid:98a79e38-fb1d-30b7-7afc-60b57b9e5bde)> 2023-04-26 19:47:13 DEBUG music_assistant.providers.dlna -- Received event for Player Kodi (DLNA-Linx-Mint): <UpnpService(urn:upnp-org:serviceId:AVTransport, uuid:98a79e38-fb1d-30b7-7afc-60b57b9e5bde)> 2023-04-26 19:47:13 DEBUG music_assistant.event -- queue_updated uuid:98a79e38-fb1d-30b7-7afc-60b57b9e5bde 2023-04-26 19:47:13 DEBUG music_assistant.event -- player_updated uuid:98a79e38-fb1d-30b7-7afc-60b57b9e5bde 2023-04-26 19:47:24 DEBUG aiohttp.server -- Ignored premature client disconnection 2 2023-04-26 19:47:24 DEBUG aiohttp.server -- Ignored premature client disconnection. 2023-04-26 19:47:24 DEBUG music_assistant.websocket_api -- [140417068596304] Unsubscribed from events 2023-04-26 19:47:24 DEBUG music_assistant.websocket_api -- [140417068596304] Disconnected 2023-04-26 19:47:24 DEBUG aiohttp.server -- Ignored premature client disconnection.

OzGav commented 1 year ago

@gost4711 you didn’t respond to @erkr suggestions. Did you try each suggestion and if so what was the outcome?

gost4711 commented 1 year ago

Sorry, I've tried everything, of course, but nothing has changed. Only with "Enable flow mode" does it take a little longer before the play button can be seen again.

gost4711 commented 1 year ago

I now use Airplay with shairport as a workaround. Airplay works fine now, but not with Kodi either

OzGav commented 1 year ago

Yes there are some issues with Kodi it seems. My (older) kodi box is not detected at all in the latest betas and previoulsy when it was Airplay did not work.

OzGav commented 1 year ago

@gost4711 I've seen improvement in the detection of kodi players in the latest beta so please advise if this is still an issue in beta32

gost4711 commented 1 year ago

The KODI Player is recognized, but playback does not work. I can press the play button, then it takes 2 seconds and the play button is ready again.

OzGav commented 1 year ago

In the player settings can you try a different output coded and see if that makes a difference?

gost4711 commented 1 year ago

Unfortunately, that doesn't change anything. I now use AirPlay and am satisfied.

OzGav commented 1 year ago

I just did a test myself and I also still have issues with Kodi (version 18.9) so I am keeping this open. When using as a DLNA player I get:

2023-05-31 10:46:23 ERROR music_assistant.websocket_api  -- [547413405776] Error handling message: CommandMessage(message_id=12, command='players/queue/play_media', args={'queue_id': 'uuid:9e2ae774-0bd7-26e3-002c-8926b6177500', 'media': {'item_id': '77', 'provider': 'database', 'name': "Livin' on the Edge", 'provider_mappings': [{'item_id': "Aerosmith/Get a Grip/Aerosmith - Livin' on the edge.mp3", 'provider_domain': 'filesystem_smb', 'provider_instance': 'filesystem_smb', 'available': True, 'content_type': 'mp3', 'sample_rate': 44100, 'bit_depth': 16, 'bit_rate': 112403, 'details': None, 'url': None}], 'metadata': {'description': None, 'review': None, 'explicit': None, 'images': [{'type': 'thumb', 'path': "Aerosmith/Get a Grip/Aerosmith - Livin' on the edge.mp3", 'provider': 'filesystem_smb'}], 'genres': ['Rock'], 'mood': None, 'style': None, 'copyright': None, 'lyrics': None, 'ean': None, 'label': None, 'links': None, 'chapters': [], 'performers': None, 'preview': None, 'replaygain': None, 'popularity': None, 'last_refresh': None, 'checksum': '1587788939'}, 'in_library': False, 'media_type': 'track', 'sort_name': "livin' on the edge", 'uri': 'database://track/77', 'timestamp_added': 1685183549, 'timestamp_modified': 1685183549, 'duration': 368, 'version': '', 'isrc': [], 'musicbrainz_id': '5f1ba3ff-d694-4ca3-92cc-27085aba0281', 'artists': [{'item_id': '4', 'provider': 'database', 'name': 'Aerosmith', 'provider_mappings': [], 'metadata': {'description': None, 'review': None, 'explicit': None, 'images': None, 'genres': None, 'mood': None, 'style': None, 'copyright': None, 'lyrics': None, 'ean': None, 'label': None, 'links': None, 'chapters': None, 'performers': None, 'preview': None, 'replaygain': None, 'popularity': None, 'last_refresh': None, 'checksum': None}, 'in_library': False, 'media_type': 'artist', 'sort_name': 'aerosmith', 'uri': 'database://artist/4', 'timestamp_added': 0, 'timestamp_modified': 0, 'musicbrainz_id': None}], 'album': {'item_id': '12', 'provider': 'database', 'name': 'Get a Grip', 'provider_mappings': [], 'metadata': {'description': None, 'review': None, 'explicit': None, 'images': None, 'genres': None, 'mood': None, 'style': None, 'copyright': None, 'lyrics': None, 'ean': None, 'label': None, 'links': None, 'chapters': None, 'performers': None, 'preview': None, 'replaygain': None, 'popularity': None, 'last_refresh': None, 'checksum': None}, 'in_library': False, 'media_type': 'album', 'sort_name': 'get a grip', 'uri': 'database://album/12', 'timestamp_added': 0, 'timestamp_modified': 0, 'version': '', 'year': None, 'artists': [], 'album_type': 'unknown', 'barcode': [], 'musicbrainz_id': None}, 'albums': [{'media_type': 'album', 'item_id': '12', 'provider': 'database', 'name': 'Get a Grip', 'sort_name': 'get a grip', 'uri': 'database://album/12', 'version': '', 'available': True, 'disc_number': 1, 'track_number': 5}], 'disc_number': 1, 'track_number': 5, 'position': None}, 'option': 'play'})
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/xml/etree/ElementTree.py", line 1709, in feed
    self.parser.Parse(data, False)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 736
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/music_assistant/server/providers/websocket_api/__init__.py", line 237, in _run_handler
    result = await result
             ^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/music_assistant/server/controllers/player_queues.py", line 240, in play_media
    await self.play_index(queue_id, cur_index)
  File "/usr/local/lib/python3.11/site-packages/music_assistant/server/controllers/player_queues.py", line 487, in play_index
    await player_prov.cmd_play_media(
  File "/usr/local/lib/python3.11/site-packages/music_assistant/server/providers/dlna/__init__.py", line 100, in wrapper
    return await func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/music_assistant/server/providers/dlna/__init__.py", line 298, in cmd_play_media
    await self.poll_player(dlna_player.udn)
  File "/usr/local/lib/python3.11/site-packages/music_assistant/server/providers/dlna/__init__.py", line 355, in poll_player
    await dlna_player.device.async_update(do_ping=do_ping)
  File "/usr/local/lib/python3.11/site-packages/async_upnp_client/profiles/dlna.py", line 349, in async_update
    await self._async_poll_state_variables(
  File "/usr/local/lib/python3.11/site-packages/async_upnp_client/profiles/profile.py", line 469, in _async_poll_state_variables
    self._on_event(service, changed_state_variables)
  File "/usr/local/lib/python3.11/site-packages/async_upnp_client/profiles/dlna.py", line 380, in _on_event
    self._update_av_transport_uri_metadata(state_variable)
  File "/usr/local/lib/python3.11/site-packages/async_upnp_client/profiles/dlna.py", line 1257, in _update_av_transport_uri_metadata
    items = didl_lite.from_xml_string(xml, strict=False)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/didl_lite/didl_lite.py", line 1065, in from_xml_string
    xml_el = defusedxml.ElementTree.fromstring(xml_string)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/defusedxml/common.py", line 126, in fromstring
    parser.feed(text)
  File "/usr/local/lib/python3.11/xml/etree/ElementTree.py", line 1711, in feed
    self._raiseerror(v)
  File "/usr/local/lib/python3.11/xml/etree/ElementTree.py", line 1618, in _raiseerror
    raise err
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 1, column 736
2023-05-31 10:46:24 ERROR music_assistant.streams  -- Player KodiRumpus is making multiple requests for the same stream, please create an issue report on the Music Assistant issue tracker.
2023-05-31 10:46:24 ERROR music_assistant.streams  -- Player KodiRumpus is making multiple requests for the same stream, please create an issue report on the Music Assistant issue tracker.
OzGav commented 1 year ago

When enabling the Airplay Kodi player I get:

2023-05-31 10:48:25 INFO  music_assistant  -- Loaded player provider Airplay
2023-05-31 10:48:25 INFO  music_assistant.players  -- Player registered: aa:aa:63:51:04:0a/squeezeplay: aa:aa:63:51:04:0a
2023-05-31 10:49:25 ERROR music_assistant.websocket_api  -- [547810702416] Error handling message: CommandMessage(message_id=40, command='players/queue/play_index', args={'queue_id': '80:1f:02:ab:1b:53', 'index': '75c2a5d875954d66a52bae987a5cc9e2'})
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/music_assistant/server/providers/websocket_api/__init__.py", line 237, in _run_handler
    result = await result
             ^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/music_assistant/server/controllers/player_queues.py", line 478, in play_index
    raise FileNotFoundError(f"Unknown index/id: {index}")
FileNotFoundError: Unknown index/id: None
2023-05-31 10:49:33 WARNING asyncio  -- Executing <Task finished name='Task-51867' coro=<SlimClient._process_helo() done, defined at /usr/local/lib/python3.11/site-packages/aioslimproto/client.py:504> result=None created at /usr/local/lib/python3.11/asyncio/tasks.py:374> took 0.182 seconds
2023-05-31 10:50:47 WARNING asyncio  -- Executing <Handle _chain_future.<locals>._set_state(<Future finis...events.py:427>, <Future at 0x... returned str>) at /usr/local/lib/python3.11/asyncio/futures.py:381 created at /usr/local/lib/python3.11/asyncio/futures.py:403> took 0.208 seconds
gost4711 commented 1 year ago

Since AirPlay didn't work with Kodi either, I installed "Shairport" on a Raspberry Zero. This works really well. Nevertheless, thank you for your efforts.

marcelveldt commented 1 year ago

this one should be fixed and Kodi is useable as playback target for both airplay and dlna