diff --git a/modules/music_player/music_player.py b/modules/music_player/music_player.py index 71fad64..c6ad853 100644 --- a/modules/music_player/music_player.py +++ b/modules/music_player/music_player.py @@ -7,6 +7,7 @@ from modules.music_player.backends.myth_music import Backend from modules.music_player.lastFM_interface import lastFM_interface from modules.music_player.music_object_row import MusicObjectRow from modules.music_player.playlist import Playlist +from modules.music_player.play_screen import PlayScreen from ui_elements.image_frame import ImageFrame from ui_elements.image_clone import ImageClone from ui_elements.label_list import LabelList @@ -33,6 +34,7 @@ class Module: self.playlist = Playlist(self) self.artistImageRow = MusicObjectRow(self.glossMgr, self.stage.get_width(), 200, self.num_columns, self) + self.play_screen = PlayScreen(self) #This is the current input context self.current_context = self.CONTEXT_ROW @@ -106,6 +108,9 @@ class Module: self.playlist.add_songs(songs) self.playlist.play() + self.play_screen.append_playlist(self.playlist) + self.play_screen.display(self.artistImageRow.get_current_texture().get_texture()) + elif self.current_context == self.CONTEXT_ALBUM_LIST: if (event.keyval == clutter.keysyms.Up): diff --git a/modules/music_player/play_screen.py b/modules/music_player/play_screen.py new file mode 100644 index 0000000..533bf6a --- /dev/null +++ b/modules/music_player/play_screen.py @@ -0,0 +1,66 @@ +import clutter +from modules.music_player.playlist import Playlist +from ui_elements.image_frame import ImageFrame +from ui_elements.image_clone import ImageClone +from ui_elements.label_list import LabelList + +class PlayScreen(clutter.Group): + + + def __init__(self, musicPlayer): + clutter.Group.__init__(self) + + self.musicPlayer = musicPlayer + self.glossMgr = musicPlayer.glossMgr + self.stage = self.glossMgr.get_stage() + + self.main_img = None + self.song_list = LabelList(8) + self.playlist = Playlist(musicPlayer) + + self.setup() + + def setup(self): + self.song_list.setup_from_theme_id(self.glossMgr.themeMgr, "music_play_screen_songs") + + def append_playlist(self, playlist): + self.playlist.add_songs(playlist.songs) + + def display(self, image): + self.timeline = clutter.Timeline(80,160) + self.alpha = clutter.Alpha(self.timeline, clutter.ramp_inc_func) + self.opacity_behaviour = clutter.BehaviourOpacity(opacity_start=0, opacity_end=255, alpha=self.alpha) + + #Create a backdrop for the player. In this case we just use the same background as the menus + #self.backdrop = glossMgr.get_themeMgr().get_texture("music_play_screen_background", None, None) + self.backdrop = clutter.Rectangle(clutter.color_parse('Black')) + self.backdrop.set_size(self.stage.get_width(), self.stage.get_height()) + self.backdrop.set_opacity(0) + self.backdrop.show() + self.add(self.backdrop) + self.opacity_behaviour.apply(self.backdrop) + + self.main_img = ImageClone(image) + self.main_img.show() + self.add(self.main_img) + + x = int( (self.stage.get_width() - self.main_img.get_width()) / 2 ) + y = int( (self.stage.get_height() - self.main_img.get_height()) / 2 ) + knots = (\ + (int(self.main_img.get_x()), int(self.main_img.get_y()) ),\ + (x, y)\ + ) + self.path_behaviour = clutter.BehaviourPath(knots = knots, alpha = self.alpha) + self.path_behaviour.apply(self.main_img) + + for song in self.playlist.songs: + self.song_list.add_item(song.name) + self.opacity_behaviour.apply(self.song_list) + self.song_list.set_opacity(0) + self.song_list.show() + self.add(self.song_list) + + self.show() + self.stage.add(self) + + self.timeline.start() \ No newline at end of file diff --git a/multimedia/AudioController.py b/multimedia/AudioController.py index 266e102..7268b22 100644 --- a/multimedia/AudioController.py +++ b/multimedia/AudioController.py @@ -7,7 +7,7 @@ class AudioController(MediaController): def __init__(self, glossMgr): MediaController.__init__(self, glossMgr) - + self.isPlaying = False """ # Primary audio object self.audio = clutter.cluttergst.Audio() @@ -26,7 +26,9 @@ class AudioController(MediaController): #self.osd.enter() def play_audio(self, uri): - print "Playing audio %s" % uri + if self.isPlaying: + self.audio.set_playing(False) + # Primary audio object self.audio = clutter.cluttergst.Audio() self.audio.connect("eos", self.stream_complete) diff --git a/themes/Pear/music_play_screen.xml b/themes/Pear/music_play_screen.xml new file mode 100644 index 0000000..7201472 --- /dev/null +++ b/themes/Pear/music_play_screen.xml @@ -0,0 +1,38 @@ + + + + + Tahoma + 30 + 38 + 30 + 25 + + + + 40% + 40% + + + 40% + 50% + + + 0 + 4 + + + 255 + 135 + 135 + 1 + 1 + 1 + + 30 + 10 + + + + diff --git a/ui_elements/image_clone.py b/ui_elements/image_clone.py index 119440a..82f40b1 100644 --- a/ui_elements/image_clone.py +++ b/ui_elements/image_clone.py @@ -12,7 +12,8 @@ class ImageClone(clutter.CloneTexture): def __init__(self, texture): clutter.CloneTexture.__init__(self, texture) - self.set_size(texture.get_x(), texture.get_y()) + (width, height) = texture.get_abs_size() + self.set_size(width, height) self.set_opacity(texture.get_opacity()) (abs_x, abs_y) = texture.get_abs_position() self.set_position(abs_x, abs_y) diff --git a/ui_elements/image_frame.py b/ui_elements/image_frame.py index 3993c17..e480c76 100644 --- a/ui_elements/image_frame.py +++ b/ui_elements/image_frame.py @@ -94,4 +94,7 @@ class ImageFrame(clutter.Group): self.add(self.reflection) self.reflection.show() else: - self.reflection = None \ No newline at end of file + self.reflection = None + + def get_texture(self): + return self.main_pic \ No newline at end of file