diff --git a/modules/music_player/backends/myth_music.py b/modules/music_player/backends/myth_music.py
index 8d8108e..573e7a0 100644
--- a/modules/music_player/backends/myth_music.py
+++ b/modules/music_player/backends/myth_music.py
@@ -25,7 +25,8 @@ class Backend(gobject.GObject):
self.dbMgr = music_player.dbMgr
self.directories = {}
- self.cache_artists = []
+ self.cache_artists = {}
+ self.cache_albums = {}
self.cache_albums_by_artistID = {}
self.cache_songs_by_albumID = {}
self.cache_songs_by_artistID = {}
@@ -51,7 +52,7 @@ class Backend(gobject.GObject):
def get_artists(self, no_cache = False):
#Check cache
if (not no_cache) and (len(self.cache_artists) > 0):
- return self.cache_artists
+ return self.cache_artists.values()
#Load the sql
sql = "SELECT * FROM music_artists ORDER BY artist_name"
@@ -75,11 +76,60 @@ class Backend(gobject.GObject):
tempArtist.import_from_mythObject(record)
artists.append(tempArtist)
#self.artistImageRow.add_object(tempArtist)
- time.sleep(0.01) #Arbitary sleep time to avoid CPU bound status
+ #time.sleep(0.01) #Arbitary sleep time to avoid CPU bound status
+ self.cache_artists[tempArtist.artistID] = tempArtist
- self.cache_artists = artists
return artists
+ def get_artist_by_ID(self, id, no_cache = False):
+ #Check cache
+ if (not no_cache) and (len(self.cache_artists) > 0):
+ return self.cache_artists[id]
+ else:
+ self.get_artists()
+ self.cache_artists[id]
+
+ #Returns a list of all album objects
+ def get_albums(self, no_cache = False):
+ #Check cache
+ if (not no_cache) and (len(self.cache_albums) > 0):
+ return self.cache_albums.values()
+
+ #Load the sql
+ sql = "SELECT * FROM music_albums ORDER BY album_name"
+ if self.music_player.glossMgr.debug: print "Music Albums SQL: " + sql
+
+ #results = self.dbMgr.run_sql(sql)
+ dbMgr = mythDB()
+ results = dbMgr.run_sql(sql)
+ dbMgr.close_db()
+
+ #Check for null return
+ if results == None:
+ print "MusicPlayer: No connection to DB or no albums found in DB"
+ return None
+
+ albums = []
+ #Else add the entries in
+ for record in results:
+ tempAlbum = album(self.music_player)
+ tempAlbum.import_from_mythObject(record)
+ albums.append(tempAlbum)
+ #self.artistImageRow.add_object(tempArtist)
+ #time.sleep(0.01) #Arbitary sleep time to avoid CPU bound status
+ self.cache_albums[tempAlbum.albumID] = tempAlbum
+
+ return albums
+
+ #Return a specific album based on its ID
+ def get_album_by_ID(self, id, no_cache = False):
+ #Check cache
+ if (not no_cache) and (len(self.cache_albums) > 0):
+ return self.cache_albums[id]
+ else:
+ self.get_albums()
+ self.cache_albums[id]
+
#Given an artistID, returns a list of albums for them
def get_albums_by_artistID(self, id, no_cache = False):
#Check cache
diff --git a/modules/music_player/play_screen.py b/modules/music_player/play_screen.py
index 0756905..aa0287e 100644
--- a/modules/music_player/play_screen.py
+++ b/modules/music_player/play_screen.py
@@ -19,6 +19,10 @@ class PlayScreen(clutter.Group):
self.main_img = None
self.song_list = LabelList(8)
self.playlist = musicPlayer.playlist #Playlist(musicPlayer)
+ self.song_details = SongDetails(self)
+
+ #Connect to "song-change" on playlist so any details can be updated
+ self.playlist.connect("song-change", self.set_song_cb)
controller = self.playlist.audio_controller
self.progress_bar = ProgressBar(controller)
@@ -84,6 +88,12 @@ class PlayScreen(clutter.Group):
self.song_list.show()
self.add(self.song_list)
+ #self.song_details.set_song(self.playlist.current_song)
+ self.song_details.set_opacity(0)
+ self.opacity_behaviour.apply(self.song_details)
+ self.song_details.show()
+ self.add(self.song_details)
+
self.add(self.progress_bar)
x = (self.stage.get_width() - self.progress_bar.get_width())/2
self.progress_bar.set_position(x, 650)
@@ -96,4 +106,60 @@ class PlayScreen(clutter.Group):
def undisplay(self):
self.playlist.stop()
- self.hide()
\ No newline at end of file
+ self.hide()
+
+ def set_song(self, song):
+ self.song_details.set_song(song)
+ #***INSERT IMAGE UPDATE HERE***
+
+ def set_song_cb(self, data, song):
+ self.set_song(song)
+
+"""
+This is a Clutter group containing labels only that
+describe the current song being played
+"""
+class SongDetails(clutter.Group):
+
+ def __init__(self, playScreen, song=None):
+ clutter.Group.__init__(self)
+
+ self.themeMgr = playScreen.glossMgr.themeMgr
+ self.backend = playScreen.musicPlayer.backend
+
+ self.setup()
+ self.show_all()
+
+ def setup(self):
+ #Create all the various labels
+ self.artist_heading = self.themeMgr.get_label("music_play_screen_artist_heading", parent = self)
+ self.album_heading = self.themeMgr.get_label("music_play_screen_album_heading", parent = self)
+ self.song_heading = self.themeMgr.get_label("music_play_screen_song_heading", parent = self)
+
+ self.artist = self.themeMgr.get_label("music_play_screen_artist", parent = self)
+ self.album = self.themeMgr.get_label("music_play_screen_album", parent = self)
+ self.song = self.themeMgr.get_label("music_play_screen_song", parent = self)
+ self.song.set_color(clutter.Color(0xff, 0xff, 0xff, 0xdd))
+
+ self.add(self.artist_heading)
+ self.add(self.album_heading)
+ self.add(self.song_heading)
+ self.add(self.artist)
+ self.add(self.album)
+ self.add(self.song)
+
+ def set_song(self, song):
+
+ self.song.set_text(song.name)
+
+ artist = self.backend.get_artist_by_ID(song.artistID)
+ if artist is None:
+ self.artist.set_text("unknown artist")
+ else:
+ self.artist.set_text(artist.name)
+
+ album = self.backend.get_album_by_ID(song.albumID)
+ if album is None:
+ self.album.set_text("unknown album")
+ else:
+ self.album.set_text(album.name)
\ No newline at end of file
diff --git a/modules/music_player/playlist.py b/modules/music_player/playlist.py
index d1f8be7..c9caeec 100644
--- a/modules/music_player/playlist.py
+++ b/modules/music_player/playlist.py
@@ -1,6 +1,15 @@
+import gobject
from multimedia.AudioController import AudioController
-class Playlist:
+class Playlist(gobject.GObject):
+ #Setup signals
+ __gsignals__ = {
+ "song-change": (
+ gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,)),
+ "stopped": (
+ gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [])
+ }
+
songs = []
position = 0
@@ -9,6 +18,8 @@ class Playlist:
def __init__(self, musicPlayer):
+ gobject.GObject.__init__(self)
+
self.musicPlayer = musicPlayer
self.backend = musicPlayer.backend
self.glossMgr = musicPlayer.glossMgr
@@ -29,6 +40,8 @@ class Playlist:
if self.glossMgr.debug: print "Music_Player: Attempting to play file '%s'" % current_song_filename
self.audio_controller.play_audio(current_song_uri)
+ self.emit("song-change", current_song)
+
#Called when the playback of one song finishes and the next is required
def next_song(self, data = None):
self.position += 1
@@ -37,6 +50,8 @@ class Playlist:
def stop(self):
if self.is_playing:
self.audio_controller.stop_audio()
+
+ self.emit("stopped")
def add_song(self, song):
self.songs.append(song)
diff --git a/themes/Pear/music_play_screen.xml b/themes/Pear/music_play_screen.xml
index 0791228..9ddc738 100644
--- a/themes/Pear/music_play_screen.xml
+++ b/themes/Pear/music_play_screen.xml
@@ -114,4 +114,114 @@
+
+
+
+
+
+
+
+
diff --git a/ui_elements/rounded_rectangle.py b/ui_elements/rounded_rectangle.py
index f8fbda5..8d26532 100644
--- a/ui_elements/rounded_rectangle.py
+++ b/ui_elements/rounded_rectangle.py
@@ -12,7 +12,7 @@ Clutter element
class RoundedRectangle(clutter.Group):
ARC_TO_BEZIER = 0.55228475
- RADIUS = 15
+ RADIUS = 5
MARGIN = 1
def __init__(self, width, height, colour = clutter.color_parse('Black')):
@@ -99,10 +99,12 @@ class RoundedRectangle(clutter.Group):
del self.ct
def set_width(self, new_width):
- self.texture.set_width(new_width)
+ #self.texture.set_width(new_width)
+ #self.texture.set_clip(0, 0, new_width, self.height)
self.width = new_width
self.setup_rounded_context()
self.refresh()
+
clutter.Group.set_width(self, new_width)
def set_height(self, new_height):