- Added begeiinings of current song infrastructure
This commit is contained in:
parent
988c517be6
commit
292c8606a8
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
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)
|
|
@ -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)
|
||||
|
|
|
@ -114,4 +114,114 @@
|
|||
</position>
|
||||
</progress_bar>
|
||||
|
||||
<!-- These labels make up the currently playing song details -->
|
||||
<label id="music_play_screen_song_heading">
|
||||
<font id="font">
|
||||
<face>Tahoma</face>
|
||||
<size id="default">30</size>
|
||||
<size id="1024x768">38</size>
|
||||
<size id="800x600">30</size>
|
||||
<size id="1920x1080">25</size>
|
||||
</font>
|
||||
|
||||
<dimensions type="relativeToParent">
|
||||
<width>50%</width>
|
||||
<height>15%</height>
|
||||
</dimensions>
|
||||
<position type="relativeToParent">
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
</position>
|
||||
</label>
|
||||
<label id="music_play_screen_album_heading">
|
||||
<font id="font">
|
||||
<face>Tahoma</face>
|
||||
<size id="default">30</size>
|
||||
<size id="1024x768">38</size>
|
||||
<size id="800x600">30</size>
|
||||
<size id="1920x1080">25</size>
|
||||
</font>
|
||||
|
||||
<dimensions type="relativeToParent">
|
||||
<width>50%</width>
|
||||
<height>15%</height>
|
||||
</dimensions>
|
||||
<position type="relativeToParent">
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
</position>
|
||||
</label>
|
||||
<label id="music_play_screen_artist_heading">
|
||||
<font id="font">
|
||||
<face>Tahoma</face>
|
||||
<size id="default">30</size>
|
||||
<size id="1024x768">38</size>
|
||||
<size id="800x600">30</size>
|
||||
<size id="1920x1080">25</size>
|
||||
</font>
|
||||
|
||||
<dimensions type="relativeToParent">
|
||||
<width>50%</width>
|
||||
<height>15%</height>
|
||||
</dimensions>
|
||||
<position type="relativeToParent">
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
</position>
|
||||
</label>
|
||||
<label id="music_play_screen_song">
|
||||
<font id="font">
|
||||
<face>Tahoma</face>
|
||||
<size id="default">30</size>
|
||||
<size id="1024x768">38</size>
|
||||
<size id="800x600">30</size>
|
||||
<size id="1920x1080">25</size>
|
||||
</font>
|
||||
|
||||
<dimensions type="relativeToParent">
|
||||
<width>50%</width>
|
||||
<height>15%</height>
|
||||
</dimensions>
|
||||
<position type="relativeToParent">
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
</position>
|
||||
</label>
|
||||
<label id="music_play_screen_artist">
|
||||
<font id="font">
|
||||
<face>Tahoma</face>
|
||||
<size id="default">30</size>
|
||||
<size id="1024x768">38</size>
|
||||
<size id="800x600">30</size>
|
||||
<size id="1920x1080">25</size>
|
||||
</font>
|
||||
|
||||
<dimensions type="relativeToParent">
|
||||
<width>50%</width>
|
||||
<height>15%</height>
|
||||
</dimensions>
|
||||
<position type="relativeToParent">
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
</position>
|
||||
</label>
|
||||
<label id="music_play_screen_album">
|
||||
<font id="font">
|
||||
<face>Tahoma</face>
|
||||
<size id="default">30</size>
|
||||
<size id="1024x768">38</size>
|
||||
<size id="800x600">30</size>
|
||||
<size id="1920x1080">25</size>
|
||||
</font>
|
||||
|
||||
<dimensions type="relativeToParent">
|
||||
<width>50%</width>
|
||||
<height>15%</height>
|
||||
</dimensions>
|
||||
<position type="relativeToParent">
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
</position>
|
||||
</label>
|
||||
|
||||
</gloss-theme>
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue