mikebrady / shairport-sync-metadata-reader

Sample Shairport Sync Metadata Player
MIT License
126 stars 33 forks source link

Pulling Album Art #15

Closed AlexanderTheDecent closed 6 years ago

AlexanderTheDecent commented 7 years ago

So long story short, I have Shairport-Sync set up into my vintage receiver so I can use bluetooth with it from my phone. It's awesome, so thanks for making all this.

Recently I had the idea to make an old square monitor into a stand for my records. When there isn't a record on the stand in front of the screen, I would like the screen to take the album art from whatever I'm streaming through Shairport-Sync. I don't need any text or anything, just a simple picture. So basically I just need to take whatever is playing and throw the album art on fullscreen.

I installed this metadata reader and made it run on my pi's startup, but I'm a bit confused on what the next step would be to making my raspberry pi read the data and then display it. I assume I'll be writing a basic program in Python or Java or Processing or something. I tried looking up some sample code but I couldn't find anything.

Thanks for the help!

qerub commented 7 years ago

There's a decent Python library named shairport-decoder you can use to have the metadata decoding taken care of. If you install that library and the framebuffer image viewer fbi (available in Debian/Raspbian) you can connect the two with a Python script like this:

from shairportdecoder import decoder
from subprocess import call

def event_processor(event_type, info):
  if event_type == decoder.COVERART:
    cover_file = info.write_cover_file().name
    call(["fbi", "--vt", "1", "--device", "/dev/fb0", "--noverbose", "--autozoom", cover_file])

def main():
  processor = decoder.Processor()
  processor.add_listener(event_processor)
  processor.parse("/tmp/shairport-sync-metadata")

if __name__ == "__main__":
  main()

I've tested that it works. Feel free to email me if you need help to get it started since this is probably not the right forum for help.