Not sure what the story is or where to best ask about this issue. I have an mp3 file I would like to play via the music_assistant.play_media action.
I have added a home assistant media folder as a music provider and can see the file, along with other files, in the browse window. I can select this file and play it on a player from within Music Assistant, no problem whatsoever.
However, when I attempt to play the file through the music_assistant.play_media action it plays something completely unrelated. I can play other files within that media folder with no issue via play_media action.
Here are the contents of the audio folder… I am trying to play the file latest_abc_news_bulletin.mp3
It seems to disregard the file name, activate a search based upon it and plays what it thinks best. How can a play a specific file via the music assistant integration?
I’ve checked the file permissions, nothing unusual as far as I can see.
Hi,
Is this code generated via Developer Tools > Actions & if not, do you see the same result if you manually test this out via dev tools > actions?
Nick
Thanks for responding… Yeah, I’ve tried various ways. In developer tools and in an automation I am working on. The integration seems to generate a search and returns a podcast based on that result rather than just playing the file that is in the library.
Tried renaming the file as well. Anything with ‘news’ in the file name seems to initiate a search and plays the first result it gets. Tried with and without spaces, with and without the .mp3 extension.
Tried specifying the media type as track which gives me an error: Failed to perform the action music_assistant.play_media. Could not resolve ['news_bulletin.mp3'] to playable media item
Thanks… I placed the file into a playlist which seems to be working (though the media player will not change from ‘playing’ once it has been played).
The file I would like to play resides in a folder within the media folder. What URI should be used for that?
The page you linked to also includes a a library id together with the media id, represented by numbers in the example. Do you know where the library id be found?
That bit is confusingly worded… as I understand it, the library ID in question is tied to the media type.
If you use the music_assistant.get_library action you can select a media_type and part of the data returned will include an ID number. For example if I run the action on my MA integration one of the items returned is:
- media_type: artist
uri: library://artist/2200
name: Adam and the Ants
version: ""
image: >-
http://assets.fanart.tv/fanart/music/75d4f194-969c-4538-b789-742f3eb3d02c/artistthumb/adam-and-ants-the-568b1a04031b7.jpg
favorite: false
explicit: null
fanart_image: https://r2.theaudiodb.com/images/media/artist/fanart/xqqssw1368210627.jpg
The artist library ID for that artist is the last part of the uri, i.e. 2200, and the action to play it would look like:
action: music_assistant.play_media
data:
media_id: 2200
media_type: artist
target:
entity_id: media_player.example
I’ve tried to play the media file a few times using the file name (which I understood WAS the media ID) but it simply would not play it. Instead choosing tp play something else, seemingly at random.
So I created a playlist with the file included and this was working… for a while. Now it plays over and over on repeat instead of just once.
Calling the file directly in the media player now plays the playlist instead of the file I wish to play.
alias: Play the Day News playlist to kitchen MA player
action: music_assistant.play_media
data:
media_id: Day News
media_type: playlist
enqueue: replace
target:
entity_id: media_player.ma_kitchen
But now it plays this on repeat and I have no idea why.
It’s a fairly simple thing. Play a file on a speaker… but I just cannot get it to work.