TroyFernandes / hass-mqtt-mediaplayer

Fill out your Media Player Entity with MQTT Topics
MIT License
32 stars 18 forks source link

Jpeg as album art ? #19

Open ThunderBirrddd opened 1 week ago

ThunderBirrddd commented 1 week ago

Hey, First of all thank you so much for this awesome add-on works flawlessly totally in love with this...

I had one question can I pass my album art as a jpeg?

entity: image.xyz

TroyFernandes commented 1 week ago

So in terms of the current plugin, it will only accept a base64 encoded url.

I think it's possible to pass through a jpeg as the image, its just that the current plugin wont support that.

If you look at the example I showed in the README:

musicbee
    playing = true
    songtitle = Repeat After Me (Interlude)
    artist = The Weeknd
    volume = 86
    album = After Hours
    command = {"command": "next"}
    albumart = /9j/4AAQSkZJRgABAQEASABI ...

The albumart section would change to something like so if there was jpg support:

musicbee
        ...
    albumart = http://someip/albumart/cover.jpg

This would mean that you would have to make the image url accessible over your local network (i.e you would have to run a small webserver serving the images) so that Homeassistant could read/resolve it.

In terms of complexity & flexibility, it's much easier to support having a base64 encoded url instead.

What media source are you using?

ThunderBirrddd commented 1 week ago

okay so i am using Shairport-hass,

configuration.yaml:

mqtt:
- image:
      name: "Airplay2 Cover"
      image_topic: "airplay2/cover"
      content_type: image/jpeg

this is written on shairport syncs github

PICT -- the payload is a picture, either a JPEG or a PNG. Check the first few bytes to see which

Is there any way I can convert it to base64?

ThunderBirrddd commented 1 week ago

NVM got it working as base64 encoded I think now how do I use this sensor.cover_base64 as album art??

this is the state of my base64 entity: MjAyNC0xMS0xMVQxODowNTo0OC4xMDkwOTUrMDA6MDA=

Configuration.yaml:

sensor:
  - platform: template
    sensors:
      airplay2_cover_base64:
        value_template: >
          {% if states.image.airplay2_cover.state %}
            {{ states.image.airplay2_cover.state | base64_encode }}
          {% else %}
            No Image Available
          {% endif %}
        friendly_name: "AirPlay2 Cover in Base64"