User avatar
mark-me
Posts: 49
Joined: Fri May 01, 2015 9:15 pm

Raspberry Pi touchscreen mpd player

Fri May 01, 2015 9:30 pm

Hi there,

Do you have a huge music collection and wanted to be able to access it anywhere in your house? I do. I want my music player to be able to access my music from my NAS drive, but also want to be able to play music brought by friends
on their USB stick. These projects brought me to mpd: a great music server program that allows you to control enormous amounts of music. It makes it easy to search through your music collection and play it. mpd has many client apps by which you can control your music on loads of different devices. But... What if there's no wifi access? You must be able to control the device directly: enter the touchscreen and enter my pi-jukebox project. It's inspired by Adafruit's pi radio project https://learn.adafruit.com/raspberry-pi ... n/overview.I thought I'd like to share it with anyone having a similar project in mind. The source can be found here: https://github.com/mark-me/Pi-Jukebox, the wiki of my project and the source code documentation can be found here: http://mark-me.github.io/Pi-Jukebox/index.html.

Here are some pictures of the front end in action (bigger screenshots can be found here: https://mark-me.github.io/Pi-Jukebox/screenshots.html)
The 'now playing' screen:
Image
The playlist screen:
Image
The library screen:
Image
Doing some text searching:
Image Image
Search follow up actions:
Image
Settings screen:
ImageImageImage


Any feedback or suggestions are welcome :).

Cheers,
Mark
Last edited by mark-me on Sun May 10, 2015 2:13 pm, edited 2 times in total.

Morfeus
Posts: 19
Joined: Thu Nov 07, 2013 10:47 am

Re: Raspberry Pi touchscreen mpd player

Sat May 02, 2015 6:16 pm

Great! An app like this is really missing.

But why MPD and not Mopidy? Mopidy has a lot more features.

User avatar
mark-me
Posts: 49
Joined: Fri May 01, 2015 9:15 pm

Re: Raspberry Pi touchscreen mpd player

Sun May 03, 2015 10:32 am

Thank you for the reply Morfeus. I did stumple across Mopidy, but why I didn't go with that I don't really remember. Maybe because I had trouble with my touchscreen at the time? I'll look into it.

P4d0uch
Posts: 47
Joined: Sun Sep 16, 2012 5:01 pm

Re: Raspberry Pi touchscreen mpd player

Sun May 03, 2015 11:28 am

It would be great to make mopidy version :)

User avatar
mark-me
Posts: 49
Joined: Fri May 01, 2015 9:15 pm

Re: Raspberry Pi touchscreen mpd player

Sun May 03, 2015 11:52 am

P4d0uch wrote:It would be great to make mopidy version :)
Hi P4d0uch,

Thanks for your reply. I've looked into it and I think it should be able to use Mopidy out of the box. I found on their website MPD clients should be able to use Modipy by default (https://docs.mopidy.com/en/latest/ext/mpd/). I'll try it myself later on, since Modipy does seem a lot better. I'll report back on my effort.

Cheers,
Mark

Morfeus
Posts: 19
Joined: Thu Nov 07, 2013 10:47 am

Re: Raspberry Pi touchscreen mpd player

Sun May 03, 2015 12:23 pm

Your app will for sure work with Mopidy, as Mopidy provides a MPD layer.

I just asked because Mopidy has so many features mpd doesn't, like Spotify, Soundcloud, Google Music etc.

If you could make a Mopidy version in the future, that would really be great!

Thanks for your work!

User avatar
mark-me
Posts: 49
Joined: Fri May 01, 2015 9:15 pm

Re: Raspberry Pi touchscreen mpd player

Sun May 03, 2015 12:36 pm

Morfeus wrote:Your app will for sure work with Mopidy, as Mopidy provides a MPD layer.

I just asked because Mopidy has so many features mpd doesn't, like Spotify, Soundcloud, Google Music etc.

If you could make a Mopidy version in the future, that would really be great!

Thanks for your work!
Yes you're right: the features are great! I'll surely look into it. First I'm going to do some hardware work. All I have now is a loose amp-board and speakers hooked up on my Raspberry Pi. I'm going to put that in a nice encasing and then I'm going to look into the Modipy version.

P4d0uch
Posts: 47
Joined: Sun Sep 16, 2012 5:01 pm

Re: Raspberry Pi touchscreen mpd player

Sun May 03, 2015 2:43 pm

Yes, it works but only with local library and i mainly use Spotify :)

User avatar
mark-me
Posts: 49
Joined: Fri May 01, 2015 9:15 pm

Re: Raspberry Pi touchscreen mpd player

Sun May 03, 2015 3:05 pm

P4d0uch wrote:Yes, it works but only with local library and i mainly use Spotify :)
Yes... I'm a strange duck still playing everything locally ;-). I I'll dive into it as soon as I understand the Mopidy server better.

User avatar
mark-me
Posts: 49
Joined: Fri May 01, 2015 9:15 pm

Re: Raspberry Pi touchscreen mpd player

Sun May 03, 2015 6:32 pm

After some searching I found something like this already exists: https://github.com/9and3r/mopidy-touchscreen. :)

P4d0uch
Posts: 47
Joined: Sun Sep 16, 2012 5:01 pm

Re: Raspberry Pi touchscreen mpd player

Sun May 03, 2015 7:00 pm

Yes it is, but as far as i know searching is not working

User avatar
mark-me
Posts: 49
Joined: Fri May 01, 2015 9:15 pm

Re: Raspberry Pi touchscreen mpd player

Sun May 03, 2015 7:05 pm

Up to me to make a working one then :-).

Morfeus
Posts: 19
Joined: Thu Nov 07, 2013 10:47 am

Re: Raspberry Pi touchscreen mpd player

Mon May 04, 2015 6:38 am

Yours is much nicer, Mark.

P4d0uch
Posts: 47
Joined: Sun Sep 16, 2012 5:01 pm

Re: Raspberry Pi touchscreen mpd player

Mon May 04, 2015 12:14 pm

That's trure. One thing I have noticed, at least on my Rpi, the mopidy-touchscreen is much faster, but its probably because it uses mopidy api

User avatar
mark-me
Posts: 49
Joined: Fri May 01, 2015 9:15 pm

Re: Raspberry Pi touchscreen mpd player

Mon May 04, 2015 1:42 pm

Yes. You're probably right. I used the command line mpc tool which might be slower. I also wouldn't want to rule out the possibility that I didn't program some stuff too efficiently since I'm new to python. But I hope to improve performance. I found it workable though.

User avatar
mark-me
Posts: 49
Joined: Fri May 01, 2015 9:15 pm

Re: Raspberry Pi touchscreen mpd player

Mon May 04, 2015 1:43 pm

Morfeus wrote:Yours is much nicer, Mark.
Thanks Morfeus. I'm trying to make it look clean and usable :-)

P4d0uch
Posts: 47
Joined: Sun Sep 16, 2012 5:01 pm

Re: Raspberry Pi touchscreen mpd player

Mon May 04, 2015 2:36 pm

mark-me wrote:Yes. You're probably right. I used the command line mpc tool which might be slower. I also wouldn't want to rule out the possibility that I didn't program some stuff too efficiently since I'm new to python. But I hope to improve performance. I found it workable though.
I dont know if this causes any problem but your program keeps disconnecting and connecting every second as new client. I guess that you check the state and use it to get the time.
I think there has to be a better way to stay connected the whole time.

User avatar
mark-me
Posts: 49
Joined: Fri May 01, 2015 9:15 pm

Re: Raspberry Pi touchscreen mpd player

Mon May 04, 2015 2:49 pm

P4d0uch wrote:
mark-me wrote:Yes. You're probably right. I used the command line mpc tool which might be slower. I also wouldn't want to rule out the possibility that I didn't program some stuff too efficiently since I'm new to python. But I hope to improve performance. I found it workable though.
I dont know if this causes any problem but your program keeps disconnecting and connecting every second as new client. I guess that you check the state and use it to get the time.
I think there has to be a better way to stay connected the whole time.
You're right that's what I do. I first tried making use of a python mpd API, but I couldn't even begin to understand those. Then I tried making use of the mpc idle command. It looked promising, but then I needed to do some process spawning and cross process communication. This didn't seem like a walk in the park either and I stumbled from one problem to the next. Then I thought: what the heck, it's not pretty, but just use mpc commands already...

Now I'm thinking more about looking into the mpd python APIs again... To be continued....

P4d0uch
Posts: 47
Joined: Sun Sep 16, 2012 5:01 pm

Re: Raspberry Pi touchscreen mpd player

Mon May 04, 2015 2:55 pm

I tried to use python-mpd 2 https://github.com/Mic92/python-mpd2/bl ... README.rst and it is not hard to use. I just couldnt get the GUI doing what i wanted :). I have no python experience whatsoever.

User avatar
mark-me
Posts: 49
Joined: Fri May 01, 2015 9:15 pm

Re: Raspberry Pi touchscreen mpd player

Mon May 04, 2015 3:00 pm

P4d0uch wrote:I tried to use python-mpd 2 https://github.com/Mic92/python-mpd2/bl ... README.rst and it is not hard to use. I just couldnt get the GUI doing what i wanted :). I have no python experience whatsoever.
Oooohhh... This looks understandable... I think I'm going to use that... I'll do some tests this evening and I'll get back to you on how it's working out.

User avatar
mark-me
Posts: 49
Joined: Fri May 01, 2015 9:15 pm

Re: Raspberry Pi touchscreen mpd player

Mon May 04, 2015 4:52 pm

OK... I got it to connect, read out the playlist. So I gather I can get the rest working. I see the approach taken for storing data is different than I did, so I have to rework the mpd stuff, but that's OK. I like doing it this way more than what I did before; that felt kind of messy anyway. Thanks for pointing this out to me!

Edit:
Well... A lot is implemented now, but a few things have me stumped:
- Track time: what is the time format used? I haven't got a clue at the moment. It isn't seconds...
- Free form finding: I can't get a result based on part of a string. How do I find Nick Cave when giving in the search ick...?

I have some things to do still:
- Adding search results to the playlist.

But all in all I think it will all be there, and I really want it to work with the library. By the way, I didn't upload all this stuff: I want it to work first.

Edit:
- Adding search results to the playlist: done...

Now I'm going to do something else before my eyes go square.

P4d0uch
Posts: 47
Joined: Sun Sep 16, 2012 5:01 pm

Re: Raspberry Pi touchscreen mpd player

Tue May 05, 2015 4:55 am

Yes the time is in seconds. I usedthis to get it like string

Code: Select all

 
if int(track_time) > 60:
    track_time_m=int(track_time)//60
    track_time_s = int(track_time)%60
track_time = str(track_time_m)+":"+str(track_time_s)
About the searching you mean searching a song in playlist? Or searching in library?

User avatar
mark-me
Posts: 49
Joined: Fri May 01, 2015 9:15 pm

Re: Raspberry Pi touchscreen mpd player

Tue May 05, 2015 9:36 am

You're right. I was looking at other time fields. Now you can find the version with python-mpd2 on github. :-). I meant searching the library. Maybe I'm looking wrong again. I can go for retrieving all results and doing the searching in the code, but I'd prefer not to since this might bring in overhead I don't need.

P4d0uch
Posts: 47
Joined: Sun Sep 16, 2012 5:01 pm

Re: Raspberry Pi touchscreen mpd player

Tue May 05, 2015 10:02 am

Wow cool. I'll try it when i get home from school :)
Edit: I'm not sure if this is what you mean, but the only way i see to find a song is to use .find() or .search() (I couldn't find a difference) and store the result. Then it is stored like list structure if i remember correctly.

User avatar
mark-me
Posts: 49
Joined: Fri May 01, 2015 9:15 pm

Re: Raspberry Pi touchscreen mpd player

Tue May 05, 2015 2:11 pm

Yes... That's right. So I do have to build my of list search... I'll do that. I changed the volume controls to make room for a cover art view I plan to do later on. Hope you like the new version.

Edit:
The partial search now works

Return to “Graphics, sound and multimedia”