Mercurial > libervia-web
comparison browser_side/radiocol.py @ 286:e76ec07be8e5
browser_side (plugin radiocol): the UI uses CaptionPanel
author | souliane <souliane@mailoo.org> |
---|---|
date | Wed, 27 Nov 2013 13:33:56 +0100 |
parents | 4f0c2fea358a |
children | 7a1dc69112b8 |
comparison
equal
deleted
inserted
replaced
285:4f0c2fea358a | 286:e76ec07be8e5 |
---|---|
27 from pyjamas.ui.Label import Label | 27 from pyjamas.ui.Label import Label |
28 from pyjamas.ui.Button import Button | 28 from pyjamas.ui.Button import Button |
29 from pyjamas.ui.ClickListener import ClickHandler | 29 from pyjamas.ui.ClickListener import ClickHandler |
30 from pyjamas.ui.Hidden import Hidden | 30 from pyjamas.ui.Hidden import Hidden |
31 from pyjamas.ui.HTML import HTML | 31 from pyjamas.ui.HTML import HTML |
32 from pyjamas.ui.CaptionPanel import CaptionPanel | |
32 from pyjamas import Window | 33 from pyjamas import Window |
33 from pyjamas.Timer import Timer | 34 from pyjamas.Timer import Timer |
34 from __pyjamas__ import JS | 35 from __pyjamas__ import JS |
35 | 36 |
36 from tools import html_sanitize | 37 from tools import html_sanitize |
79 FormPanel.__init__(self) | 80 FormPanel.__init__(self) |
80 self.setEncoding(FormPanel.ENCODING_MULTIPART) | 81 self.setEncoding(FormPanel.ENCODING_MULTIPART) |
81 self.setMethod(FormPanel.METHOD_POST) | 82 self.setMethod(FormPanel.METHOD_POST) |
82 self.setAction("upload_radiocol") | 83 self.setAction("upload_radiocol") |
83 self._parent = parent | 84 self._parent = parent |
84 | 85 vPanel = VerticalPanel() |
85 hPanel = HorizontalPanel() | 86 |
86 hPanel.setSpacing(5) | |
87 types = [('audio/ogg', '*.ogg', 'Ogg Vorbis Audio'), | 87 types = [('audio/ogg', '*.ogg', 'Ogg Vorbis Audio'), |
88 ('video/ogg', '*.ogv', 'Ogg Vorbis Video'), | 88 ('video/ogg', '*.ogv', 'Ogg Vorbis Video'), |
89 ('application/ogg', '*.ogx', 'Ogg Vorbis Multiplex')] | 89 ('application/ogg', '*.ogx', 'Ogg Vorbis Multiplex')] |
90 self.file_upload = FilterFileUpload("song", 5, types) | 90 self.file_upload = FilterFileUpload("song", 5, types) |
91 hPanel.add(self.file_upload) | 91 vPanel.add(self.file_upload) |
92 | 92 |
93 hPanel = HorizontalPanel() | |
93 self.upload_btn = Button("Upload song", getattr(self, "onBtnClick")) | 94 self.upload_btn = Button("Upload song", getattr(self, "onBtnClick")) |
94 hPanel.add(self.upload_btn) | 95 hPanel.add(self.upload_btn) |
95 | |
96 self.status = Label() | 96 self.status = Label() |
97 self.updateStatus() | 97 self.updateStatus() |
98 hPanel.add(self.status) | 98 hPanel.add(self.status) |
99 | |
100 | |
101 #We need to know the referee | 99 #We need to know the referee |
102 referee_field = Hidden('referee', self._parent.referee) | 100 referee_field = Hidden('referee', self._parent.referee) |
103 hPanel.add(referee_field) | 101 hPanel.add(referee_field) |
104 | 102 vPanel.add(hPanel) |
105 self.add(hPanel) | 103 |
104 self.add(vPanel) | |
106 self.addFormHandler(self) | 105 self.addFormHandler(self) |
107 | 106 |
108 def updateStatus(self): | 107 def updateStatus(self): |
109 # TODO: the status should be different if a song is being played or not | 108 # TODO: the status should be different if a song is being played or not |
110 queue = self._parent.getQueueSize() | 109 queue = self._parent.getQueueSize() |
188 | 187 |
189 | 188 |
190 class RadioColPanel(HorizontalPanel, ClickHandler): | 189 class RadioColPanel(HorizontalPanel, ClickHandler): |
191 | 190 |
192 def __init__(self, parent, referee, player_nick, players, queue_data): | 191 def __init__(self, parent, referee, player_nick, players, queue_data): |
193 HorizontalPanel.__init__(self) | 192 # We need to set it here and not in the CSS :( |
193 HorizontalPanel.__init__(self, Height="90px") | |
194 ClickHandler.__init__(self) | 194 ClickHandler.__init__(self) |
195 self._parent = parent | 195 self._parent = parent |
196 self.referee = referee | 196 self.referee = referee |
197 self.queue_data = queue_data | 197 self.queue_data = queue_data |
198 self.setStyleName("radiocolPanel") | 198 self.setStyleName("radiocolPanel") |
199 self.setHeight('30%') | |
200 | 199 |
201 # Now we set up the layout | 200 # Now we set up the layout |
202 self.left_panel = VerticalPanel() | |
203 self.left_panel.setStyleName("radiocol_left_panel") | |
204 self.left_panel.setHeight('100%') | |
205 self.add(self.left_panel) | |
206 self.right_panel = VerticalPanel() | |
207 self.metadata_panel = MetadataPanel() | 201 self.metadata_panel = MetadataPanel() |
208 self.right_panel.add(self.metadata_panel) | 202 self.add(CaptionPanel("Now playing", self.metadata_panel)) |
203 self.playlist_panel = VerticalPanel() | |
204 self.add(CaptionPanel("Songs queue", self.playlist_panel)) | |
209 self.control_panel = ControlPanel(self) | 205 self.control_panel = ControlPanel(self) |
210 self.right_panel.add(self.control_panel) | 206 self.add(CaptionPanel("Controls", self.control_panel)) |
211 self.add(self.right_panel) | 207 |
212 #self.right_panel.setBorderWidth(1) | |
213 self.next_songs = [] | 208 self.next_songs = [] |
214 self.players = [Player("player_%d" % i, self.metadata_panel) for i in range(4)] | 209 self.players = [Player("player_%d" % i, self.metadata_panel) for i in range(4)] |
215 self.current_player = None | 210 self.current_player = None |
216 for player in self.players: | 211 for player in self.players: |
217 self.right_panel.add(player) | 212 self.add(player) |
218 self.addClickListener(self) | 213 self.addClickListener(self) |
219 | 214 |
220 help_msg = HTML("""- This radio plays Ogg Vorbis files.<br /> | 215 help_msg = HTML("""- This radio plays Ogg Vorbis files.<br /> |
221 - What's that? I only know MP3!<br /> | 216 - What's that? I only know MP3!<br /> |
222 - Click <a style="color: red;">here</a> if you need some support :) | 217 - Click <a style="color: red;">here</a> if you need some support :) |
228 def pushNextSong(self, title): | 223 def pushNextSong(self, title): |
229 """Add a song to the left panel's next songs queue""" | 224 """Add a song to the left panel's next songs queue""" |
230 next_song = Label(title) | 225 next_song = Label(title) |
231 next_song.setStyleName("radiocol_next_song") | 226 next_song.setStyleName("radiocol_next_song") |
232 self.next_songs.append(next_song) | 227 self.next_songs.append(next_song) |
233 self.left_panel.append(next_song) | 228 self.playlist_panel.append(next_song) |
234 | 229 |
235 def popNextSong(self): | 230 def popNextSong(self): |
236 """Remove the first song of next songs list | 231 """Remove the first song of next songs list |
237 should be called when the song is played""" | 232 should be called when the song is played""" |
238 #FIXME: should check that the song we remove is the one we play | 233 #FIXME: should check that the song we remove is the one we play |
239 next_song = self.next_songs.pop(0) | 234 next_song = self.next_songs.pop(0) |
240 self.left_panel.remove(next_song) | 235 self.playlist_panel.remove(next_song) |
241 | 236 |
242 def getQueueSize(self): | 237 def getQueueSize(self): |
243 return len(self.left_panel.getChildren()) | 238 return len(self.playlist_panel.getChildren()) |
244 | 239 |
245 def radiocolPreload(self, filename, title, artist, album): | 240 def radiocolPreload(self, filename, title, artist, album): |
246 preloaded = False | 241 preloaded = False |
247 for player in self.players: | 242 for player in self.players: |
248 if not player.filename or \ | 243 if not player.filename or \ |