format of time /total,elapsed,remaining/
Time format used in mpdlcd is very good for listning local music collection, but it is not too good with very long music files or with internet radio, when sometimes it plays for more then 60 hours or something...
I suggest to move to hh:mm:ss format or to choose format in configuration file.
I would suggest to make small improvment in display_fields.py
class BaseTimeField(Field):
target_hooks = ['state', 'elapsed_and_total']
def __init__(self, **kwargs):
super(BaseTimeField, self).__init__(width=8, **kwargs)
@classmethod
def _format_time(cls, seconds):
if seconds is None:
return '--:--:--'
minutes = seconds / 60 % 60
hours = seconds / 3600
seconds = seconds % 60
return '%02d:%02d:%02d' % (hours, minutes, seconds)
def add_to_screen(self, screen, left, top):
return screen.add_string_widget(self.name, self._format_time(None),
x=left, y=top)
def state_changed(self, widget, new_state):
if new_state not in (MPD_PLAY, MPD_PAUSE):
txt = self._format_time(None)
logger.debug(u'Setting widget %s to %r', widget.ref, txt)
widget.set_text(txt)
It would be also good, to detect internet radio streams - now displaying 'remaining time' on radio streams shows some stupid things.
Hi,
I've modified the time functions to switch to "12h34" format for long setups. This isn't perfect but should improve your experience.
The patch you propose would look great for web radio, but not so much for short songs; a better option would be to set a custom (fixed width) display format.
Regarding the auto-detection of streams, I'm not using them so can't test much; but I'd be glad to add such support. If you find some magical flag in the documentation that says "hey, that's a stream", let me know! (docs: http://www.musicpd.org/doc/protocol/command_reference.html)
I don't think that this kind of flag exist, but It would be possible to detect streams when total time of song is unknown or is zero.