Tons of questions about new media browser

Hello,

I was really excited to see the announcement about the new media browser component that was lit up in most recent release (https://www.home-assistant.io/blog/2020/09/17/release-115/). Unfortunately, I have found the documentation a little lacking. I use an “unsupported installation” of Home Assistant as a “supervised” installation (honestly I just followed the linux install script that used to be linked from the install instructions - no problem with any upgrades and everything works smoothly - nothing special other than I’m on ubuntu 20.04 LTS).

Following the instructions here: https://www.home-assistant.io/more-info/local-media/setup-media/ I don’t think I should have to do anything special (“the default path home assistant will try to use, is /media”). To that end, I’ve successfully mapped a samba file share to a sub-folder of /media called “/media/music” which is in-fact browsable from ssh. However, after waiting, restarting, and reloading, the system still doesn’t seem to detect any media files.

So, here are my questions:

  • Any recommendations on how to check if /media was properly mapped? Should I be looking for a specific container to have been spun up when I run docker ps? Up until this point I haven’t had to kick any command via “run docker”, and I haven’t written any docker compose files - my system was completely configured with the installation script. Hassio starts up even after a reboot, so I have reluctance to modify any startup scripts to add the "-v /PATH_TO_YOUR_MEDIA:/media " to the systemd unit file.
  • Is it possible to have the home assistant look at a samba file share for the media browser using the configuration.yaml file (remote instead of a local directory described here: https://www.home-assistant.io/docs/configuration/basic/#media_dirs) , or achieve what I’m trying to do?
  • Does the media browser support sub-folders that organize music, or does everything have to be stuffed into a single directory with no sub folders? Will it scan recursively for content?
  • How does the media browser index content? If I were to point it at a directory with 10K of files would it slow down my home assistant’s database performance?

Thank you in advance for your help!

1 Like

No 1. Yes, you need to map your docker to a specific directory called media else that directory won’t be available for media browser
no 2. I don’t think media browsers can be set up that way.
no 3. this one I’m not sure
no 4. you can have a subfolder inside the media folder now regarding slow down unsure because I have not uploaded a lot of content to it.

I have another question…

Are media files in the /media/ folder accessible from within a script to play them on a media player?

The files in that folder do appear in Media Browser and will play using the HA UI so I have it set up correctly.

However in a script this isn’t working.

- service: media_player.play_media
  data:
    entity_id: media_player.kitchen
    media_content_id: http://192.168.1.25:8123/media/test.mp3
    media_content_type: music

but this is

- service: media_player.play_media
  data:
    entity_id: media_player.kitchen
    media_content_id: http://192.168.1.25:8123/local/sounds/test.mp3
    media_content_type: music

I also would like to know how to play media items from automations or scripts. I know that items within the www directory are “publicly” accessible. Authentication is not required to view those items. Items within the new “media” directory are NOT publicly accessible. You are required to authenticate before you can access things within the “media” directory. For example, if you cast something from the media directory to a Google Cast device and then look at the attributes of that entity, you can see the authentication token

https://ha-url.com/media/local/test.mp3?authSig=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiIzMDQ2M2I2YTU3Zjg0Yzg2YTc1YWRjMTk3NWVkNWQ4MCIs...

I haven’t done too many tests with the new media directory, but I’ve not yet been successful using it in automations/scripts/service calls.

you can put this in your configuration.yaml

homeassistant:
    media_dirs:
      media: /media
      media: /config/www/audio

en put al your media in the folder /config/www/audio
than al your media is on the same place

you can put this in your configuration.yaml

homeassistant:
    media_dirs:
      media: /media
      media: /config/www/audio

en put al your media in the folder /config/www/audio

in scripts and automations you can then use:

alias: Nieuw script
  sequence:
  - service: media_player.play_media
    data:
      entity_id: media_player.google_home
      media_content_type: music
      media_content_id: https://ha-url.com:8123/local/audio/xxx.mp3
2 Likes

Yes, I know that I can do that, I would like a way to play audio in automations without it being publicly accessible in the “www” directory.

1 Like

Shouldnt be:

      media_content_id: media-source:/media/audio/xxx.mp3

Can we also use tap_action on a card to open an mediabrowser “card” when specifying an mediaplayer? That is exactly what I need…

2 Likes

Are there controls available to play albums or to play a shuffle of a folder like in Plex?
media_content_id: 'plex://{"library_name": "Music", "artist_name": "America", "Album": "America", "shuffle": "1" }'

@klogg The following works for me in an automation. RPi 4 with HassIO

service: media_player.play_media
data:
  media_content_id: 'media-source://media_source/local/filename.mp3'
  media_content_type: music
entity_id: media_player.googlehome

2 Likes

I need shuffle too!! Did you find a solution ?

It is straightforward enough to play a single track. The question was how to play the contents of a whole album or shuffle/play the album contents.
@Marcus_Lundblad

1 Like

Easiest way is to set shuffle using custom mini media player in Lovelace. Example below is with Spotify and in this example also the lyrics are displayed. Wen clicking on the card you will notice an option to get to your Spotify playlists.
Note: the shuffle option is limited to Sonos, Spotify, Kodi, Roon, Squeezebox and Universal.

card:
  type: entities
  theme: clear-dark
  entities:
    - entity: media_player.spotify_xxx
      cards:
        - type: conditional
          conditions:
            - entity: sensor.foobar_lyrics
              state: 'on'
          card:
            type: markdown
            content: '{{ states.sensor.foobar_lyrics.attributes.media_lyrics }}'
      name: Spotify Shuffle
      artwork: full-cover-fit
      source: full
      soundmode: full
      info: scroll
      hide:
        controls: false
        power: true
        runtime: false
        shuffle: false
        volume: true
        icon_state: false
      type: 'custom:mini-media-player'
1 Like

Not for me unfortunately (using the Services Dev tool)

Logger: homeassistant.components.sonos.media_player
Source: components/sonos/media_player.py:481
Integration: Sonos ([documentation](https://www.home-assistant.io/integrations/sonos), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+sonos%22))
First occurred: 15:44:50 (15 occurrences)
Last logged: 16:04:23

Error on play_media with UPnP Error 714 received: Illegal MIME-Type from 192.168.1.234

I have Sonos not google Home but that shouldn’t make any difference.
My media folder is at the same level as my config folder.

I don’t understand why this is not documented…

Same here …

I’d like to have a dashboard button that redirects me to the media browser too. Have you found a solution?

Create a button that goes to the URL

http://ip-of-ha:8123/media-browser

This will not show the same as when you have a spotify player and use the media browser from there. We want to call a card for media browser, as pop-up. Not the media browser page

1 Like

I tried this too, but this doesn’t work using the mobile app. It launches your phone’s browser instead.