LCD display and buttons in Python (tutorial and code)

Raspberry Pi related support

Re: LCD display and buttons in Python (tutorial and code)

Postby TommyBoy » 26 Jan 2017, 18:50

any one know where in the file structure i can find song playback info ?
like tittle ? play time, remain time ? resolution ? sample rate ?
User avatar
TommyBoy
 
Posts: 111
Joined: 29 Mar 2016, 14:04
Location: Copenhagen Denmark

Re: LCD display and buttons in Python (tutorial and code)

Postby hondagx35 » 26 Jan 2017, 19:00

Hi TommyBoy,

try

Code: Select all
redis-cli get act_player_info

on the command line while playing a song.

Code: Select all
root@runeaudio(rw):~# redis-cli get act_player_info
"{\"volume\":\"66\",\"repeat\":\"0\",\"random\":\"0\",\"single\":\"0\",\"consume\":\"0\",\"playlist\":\"6\",\"playlistlength\":\"17\",\"mixrampdb\":\"0.000000\",\"state\":\"play\",\"song\":\"11\",\"songid\":\"12\",\"time\":\"258\",\"elapsed\":\"0\",\"bitrate\":\"320\",\"audio\":\"44100:24:2\",\"nextsong\":\"12\",\"nextsongid\":\"13\",\"OK\":null,\"song_percent\":0,\"audio_sample_rate\":\"44.1\",\"audio_sample_depth\":\"24\",\"audio_channels\":\"Stereo\",\"changed\":\"player\",\"currentartist\":\"3 Doors Down\",\"currentsong\":\"When I'm Gone\",\"currentalbum\":\"iTunes Originals\",\"currentcomposer\":null,\"fileext\":\"mp3\",\"file\":\"NAS\\/Musik\\/Audiophile Stream Network\\/1\\/3 Doors Down - When I'm Gone.mp3\",\"radioname\":null,\"actPlayer\":\"MPD\"}"

You will get all player info as a json encoded string.

Frank
User avatar
hondagx35
 
Posts: 3042
Joined: 11 Sep 2014, 22:06
Location: Germany

Re: LCD display and buttons in Python (tutorial and code)

Postby TommyBoy » 26 Jan 2017, 19:45

thanks so much.
however the numbers dont update ??
i hear the music play, but no time indicators move.. ??

update : if i change volume in the UI, and then ask the command as you suggest in the console
NOW i see changed time info..
can i get updated LIVE values via the console, with out need to touch the UI ?

and one other "thing" the JSON i get looks like yours, but nothing at all like the standards i can read about
here for example
https://en.wikipedia.org/wiki/JSON
User avatar
TommyBoy
 
Posts: 111
Joined: 29 Mar 2016, 14:04
Location: Copenhagen Denmark

Re: LCD display and buttons in Python (tutorial and code)

Postby TommyBoy » 27 Jan 2017, 18:36

No news / solution ?
The UI dont update either, try webradio whete they write the track they play, i need to change volume one up, and then down again, to get an update, same as with this json string,
Just too bad, i had a super idea for a display, but it just will not work, since this stuff is not live.
User avatar
TommyBoy
 
Posts: 111
Joined: 29 Mar 2016, 14:04
Location: Copenhagen Denmark

Re: LCD display and buttons in Python (tutorial and code)

Postby hondagx35 » 28 Jan 2017, 00:05

Hi TommyBoy,

The UI dont update either, try webradio whete they write the track they play, i need to change volume one up, and then down again, to get an update, same as with this json string,

it is the way mpd works. We use the command "idle" to get lowest cpu usage.
You can test this with:
Code: Select all
mpc idleloop


You can poll mpd every few seconds to get "live" data:
Code: Select all
root@runeaudio(rw):~# telnet localhost 6600
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
OK MPD 0.19.0
status
volume: 65
repeat: 0
random: 0
single: 0
consume: 0
playlist: 12
playlistlength: 17
mixrampdb: 0.000000
state: play
song: 9
songid: 10
time: 39:332
elapsed: 39.206
bitrate: 320
audio: 44100:24:2
nextsong: 10
nextsongid: 11
OK


Code: Select all
root@runeaudio(rw):~# telnet localhost 6600
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
OK MPD 0.19.0
currentsong
file: NAS/Musik/Audiophile Stream Network/1/The Jeff Healey Band - Dreams Of Love.mp3
Last-Modified: 2016-03-31T09:15:54Z
Artist: The Jeff Healey Band
AlbumArtist: The Jeff Healey Band
ArtistSort: Healey, Jeff Band, The
AlbumArtistSort: Healey, Jeff Band, The
Title: Dreams of Love
Album: Feel This
Track: 14/14
Date: 1992-09-28
Disc: 1/1
MUSICBRAINZ_ALBUMARTISTID: 9fac4087-8201-4b74-a619-e77b1602aaf4
MUSICBRAINZ_ARTISTID: 9fac4087-8201-4b74-a619-e77b1602aaf4
MUSICBRAINZ_RELEASETRACKID: 598b2321-03f5-48f0-aed6-30d21e995615
MUSICBRAINZ_ALBUMID: 5cb068ea-6697-4363-9292-c15c39d03e66
MUSICBRAINZ_TRACKID: 843e02e7-5c10-43db-9a83-bbe19de11db4
Time: 332
Pos: 9
Id: 10
OK


Frank
User avatar
hondagx35
 
Posts: 3042
Joined: 11 Sep 2014, 22:06
Location: Germany

Re: LCD display and buttons in Python (tutorial and code)

Postby TommyBoy » 28 Jan 2017, 01:03

i am sorry, I dont understand a single thing in this answer ?

WHAT exactly do I type in the console, to get that kind og cool info ?

please help ?
User avatar
TommyBoy
 
Posts: 111
Joined: 29 Mar 2016, 14:04
Location: Copenhagen Denmark

Re: LCD display and buttons in Python (tutorial and code)

Postby hondagx35 » 28 Jan 2017, 01:11

Hi,

Code: Select all
telnet localhost 6600


and after the answer from MPD
Code: Select all
status

or
Code: Select all
currentsong


See the MPD documentation for more info.

Frank
User avatar
hondagx35
 
Posts: 3042
Joined: 11 Sep 2014, 22:06
Location: Germany

Re: LCD display and buttons in Python (tutorial and code)

Postby TommyBoy » 28 Jan 2017, 01:23

OK it works in the console via putty.
but does it also work, like via a serial line ?
this way I can also access the console, right ?

by the way I dont understand the time, and elapsed in status ?
none of them reveal real length of the track ?
that is in "currentsong" info
but in secs

where do I find all telnet commands for MPD ?
User avatar
TommyBoy
 
Posts: 111
Joined: 29 Mar 2016, 14:04
Location: Copenhagen Denmark

Re: LCD display and buttons in Python (tutorial and code)

Postby hondagx35 » 28 Jan 2017, 10:06

where do I find all telnet commands for MPD ?
Let me google this for you.
User avatar
hondagx35
 
Posts: 3042
Joined: 11 Sep 2014, 22:06
Location: Germany

Re: LCD display and buttons in Python (tutorial and code)

Postby Yatsushiro » 28 Jan 2017, 11:14

hondagx35 wrote:
where do I find all telnet commands for MPD ?
Let me google this for you.


:P Frank, you have the patience of a saint.
Yatsushiro
 
Posts: 90
Joined: 11 May 2016, 10:30

support RuneAudio Donate with PayPal

PreviousNext

Return to Raspberry Pi

Who is online

Users browsing this forum: No registered users and 18 guests