- Implementation of the playing screen in music player

This commit is contained in:
noisymime 2008-05-01 14:04:34 +00:00
parent 0489e0782b
commit 8f2174b294
6 changed files with 119 additions and 4 deletions

View File

@ -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):

View File

@ -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()

View File

@ -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)

View File

@ -0,0 +1,38 @@
<gloss-theme>
<label_list id="music_play_screen_songs">
<font id="main">
<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="relativeToStage">
<width>40%</width>
<height>40%</height>
</dimensions>
<position type="relativeToStage">
<x>40%</x>
<y>50%</y>
</position>
<item_gap>0</item_gap>
<num_visible_elements>4</num_visible_elements>
<!-- These are the opacity and scale values for the 3 possible steps in the menu
Make all the values the same if you do not want these effects -->
<opacity_step0>255</opacity_step0>
<opacity_step1>135</opacity_step1>
<opacity_step2>135</opacity_step2>
<scale_step0>1</scale_step0>
<scale_step1>1</scale_step1>
<scale_step2>1</scale_step2>
<transition_fps>30</transition_fps>
<transition_frames>10</transition_frames>
</label_list>
</gloss-theme>

View File

@ -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)

View File

@ -94,4 +94,7 @@ class ImageFrame(clutter.Group):
self.add(self.reflection)
self.reflection.show()
else:
self.reflection = None
self.reflection = None
def get_texture(self):
return self.main_pic