Play audio (local MP3 file) to a media_player

Hi. I didn’t found what I was looking for in this topic, but it would be nice to give my cents to whoever gets here later.

Use this https://www.home-assistant.io/integrations/media_extractor

I could finally play audio from my HA folder and also youtube video/songs.

2 Likes

what media player are you using?

Hi everybody,
I’m new with HA and somehow struggling with the playback of a local mp3-file. I’m using the service media_player.play_media and the file is located on my HA-machine within the media-folder (subfolder audio):

service: media_player.play_media
data:
  media_content_id: 'http:/192.168.178.121:8123/media/audio/Achtung-Im-Bad-oder-WC-Fenster.mp3'
  media_content_type: music
target:
  entity_id: media_player.wohnzimmer_sonos

Unfortunately I can’t get any playback. The logfile says:

ERROR (SyncWorker_0) [homeassistant.components.sonos.media_player] Error on play_media with UPnP Error 714 received: Illegal MIME-Type from 192.168.178.54

I would be grateful for any help

1 Like

This version doesn’t work either:

service: media_player.play_media
data:
  media_content_id: >-
    http:/192.168.178.121:8123/local/media/audio/Achtung-Im-Bad-oder-WC-Fenster.mp3
  media_content_type: music
target:
  entity_id: media_player.wohnzimmer_sonos

Try accessing the url from a browser and see what happens

Try accessing the url from a browser and see what happens

I’m getting an 401-Error:

401: Unauthorized

It looks like you’re missing the second “/” after http:.

  media_content_id: 'http://192.168.178.121:8123/media/audio/Achtung-Im-Bad-oder-WC-Fenster.mp3'
  media_content_type: audio/mp3

Also, I believe there’s an issue (bug) with accessing the default media folder via URL. I ended up creating a folder named sounds under root/config/www and reference it like this:

media_content_id: 'http://192.168.0.115:8123/local/sounds/rocketlaunch.mp3'
3 Likes

You made my day. Thank you very much, with the new location under /config/www/ ist’s working like a charm.

To access the default media folder you can try:

media_content_id: /media/local/sounds/rocketlaunch.mp3

Assuming you have a folder named “sounds” in your default media folder.

CFC

2 Likes

Ciao a tutti! Vi scrivo in Italiano perchè col traduttore automatico farei di peggio. :smiley:

Per riprodurre i file locali su Hassio usando l’uscita jack 3,5 mm ho usato il seguente procedimento:

01 - Installare l’Add-On MDP Player caricando il seguente repository:https://github.com/Poeschl/Hassio-Addons

02 - Mettere spunta su “Mostra nella barra laterale”. La configurazione di MPD l’ho lasciata di default.

03 - su configuration.yaml aggiungere il seguente testo:

media_player:
platform: mpd
host: 127.0.0.1
port: 6600

Riavviate Home Assistant.

04 - Per l’esempio parlo di un file mp3 chiamato “Doorbell.mp3” però credo sia uguale anche per altre estensioni.
Usando l’estensione “Samba” posizionare i file nella cartella \HOMEASSISTANT\media\mpd\media\Doorbell.mp3

05 - Sull’interfaccia web di MDP andare su “settings/update DB/save” e vi verrà aggiornata la lista dei file disponibili.

06 - Per usare i file mp3 sulle automazioni io ho usato il seguente testo:

service: media_player.play_media
target:
entity_id: media_player.mpd
data:
media_content_id: Doorbell.mp3
media_content_type: audio/mp3

07 - Devo ancora capire come poter agire sul volume, comunque così è più che utilizzabile.

08 - Buon divertimento!

Hi. Is there anyway to do this if I have HA running as a VM in Virtualbox?

I have mine running in VMWare Fusion. I assume it’s just the same.
Use the add-on Samba Share to expose your Home Assistant files on your local network.
That’s the easiest way to get at the files. Visual Studio Code even allows you to drag and drop tiles to your directories.

Hi. I have installed Hassio on Raspi.
I want to do something simple. I want to send an mp3 audio file to Google mini when an event occurs. The audio file is stored under the media folder. Now if I launch the service from Develeper Tools the file is played, but it doesn’t work from the automation. From Google mini, only the Google assistant type sound is lacking. Anyone have an idea?


This is my automation:

- id: gg_food_waste  
  alias: gg_food_waste
  trigger:
    platform: time
    at: '17:05:00'
  condition:
    condition: time
    weekday:
      - tue
      - thu
      - sat
  action:
  - data:
      entity_id: media_player.gm
      volume_level: '0.7'
    service: media_player.volume_set
  - data:
      entity_id: media_player.gm
      media_content_id: /media/local/messaggi/Conf_Umido.mp3
      media_content_type: audio/mp3
    service: media_player.play_media  

Anything in logs?

Nothing. Unluckily

Are you sure, this is the correct path?

In my vision the path starts with /local/…

hi.
Yes also because it works if I call the service from the dev panel.
I wait for the night to pass and reflect with a fresh mind.
Thanks

any updates on this?

Just after uploading my mp3 file in multimedia/local media, i try this in the “content id” field and it works !

media-source://media_source/local/music.mp3

Placed mp3 in the “local” folder here:

/config/www/sounds/doorbell-1.mp3

called service as follows:

service: media_player.play_media
data:
  media_content_id: /local/sounds/doorbell-1.mp3
  media_content_type: music
target:
  entity_id: media_player.dining_room

Please note, using nabu casa.
If using duckdns use the full url
e.g.

service: media_player.play_media
data:
  media_content_id: https://something.duckdns.org/local/sounds/doorbell-1.mp3
  media_content_type: music
target:
  entity_id: media_player.dining_room

:

1 Like