add song duration

git-svn-id: http://www.neo1973-germany.de/svn@235 46df4e5c-bc4e-4628-a0fc-830ba316316d
main
fgau 16 years ago
parent dc6ada12da
commit e0366591f3

@ -20,7 +20,7 @@ from pyneo.dns_support import DNSCache #require: export PYTHONPATH=/usr/share/py
class AudioScreen(EdjeGroup):
toggle = 0
volume = 0.9
volume = 0.1
def __init__(self, screen_manager):
EdjeGroup.__init__(self, screen_manager, AUDIO_SCREEN_NAME)
@ -71,8 +71,15 @@ class AudioScreen(EdjeGroup):
def register_pyneo_callbacks(self):
PyneoController.register_callback("on_get_mp3_tags", self.on_get_mp3_tags)
PyneoController.register_callback("on_get_song_duration", self.on_get_song_duration)
# PyneoController.register_callback("on_get_song_position", self.on_get_song_position)
def on_get_song_duration(self, status):
self.part_text_set("duration", "%s" % time.ctime(status)[14:][:5])
print '--- current song length: ', status
def on_get_mp3_tags(self, status):
PyneoController.get_song_duration()
try:
self.image.delete()
except:
@ -80,12 +87,10 @@ class AudioScreen(EdjeGroup):
self.part_text_set("mp3_tags", "artist: %s<br>album: %s<br>title: %s" % (status['artist'], status['album'], status['title']))
if not os.path.isfile(COVER_FILE_PATH + '%s_%s.jpeg' % (status['artist'], status['album'])):
try:
content = self.get_amazon_cover(status['artist'], status['album'])
with open(COVER_FILE_PATH + '%s_%s.jpeg' % (status['artist'], status['album']), 'w') as f:
f.write(content)
except:
pass # display a dummy cover
print '--- cover not exists'
content = self.get_amazon_cover(status['artist'], status['album'])
with open(COVER_FILE_PATH + '%s_%s.jpeg' % (status['artist'], status['album']), 'w') as f:
f.write(content)
self.image = self.evas.Image(file=COVER_FILE_PATH + '%s_%s.jpeg' % (status['artist'], status['album']))
x, y = self.image.image_size

@ -289,6 +289,22 @@ collections {
rel2 { relative: 1/2 1/2; offset: 80 80; }
}
} /*end icon swallow */
part {
name: "duration";
type: TEXT;
mouse_events: 0;
description {
state: "default" 0;
color_class: "button_inactive";
rel1 { relative: 6/8 3/8; }
rel2 { relative: 1 4/8; }
text {
size: 20;
font: "VeraBd";
fit: 1 1;
}
}
}
key("track_left", 0, 2)
key("stop", 1, 2)
key_play_pause("play_pause", "play", "pause", 2, 2)

@ -554,6 +554,14 @@ class PyneoController(object):
def stop_ringtone(class_):
class_.mp3.StopRingtone(dbus_interface='org.pyneo.Music')
@classmethod
def get_song_duration(class_):
class_.notify_callbacks("on_get_song_duration", class_.mp3.GetSongDuration(dbus_interface='org.pyneo.Music'))
@classmethod
def get_song_position(class_):
class_mp3.GetSongPosition(dbus_interface='org.pyneo,Music')
@classmethod
def db_check(class_):
if not os.path.exists(DB_FILE_PATH):
@ -601,6 +609,7 @@ class Dialer(object):
PyneoController.register_callback("show_sms_screen_detail", self.on_sms_screen_detail)
PyneoController.register_callback("show_weather_screen", self.on_weather_screen)
PyneoController.register_callback("show_audio_screen", self.on_audio_screen)
# PyneoController.register_callback("on_get_song_duration", self.on_get_song_duration)
# Initialize the D-Bus interface to pyneo
dbus_ml = e_dbus.DBusEcoreMainLoop()

Loading…
Cancel
Save