Mercurial > libervia-web
comparison browser_side/radiocol.py @ 397:6148e9063069
browser_side: radiocol displays who uploaded the file with ChatPanel.printInfo
author | souliane <souliane@mailoo.org> |
---|---|
date | Tue, 11 Mar 2014 11:53:03 +0100 |
parents | ee61b0765d6c |
children | 462fc3359ee3 |
comparison
equal
deleted
inserted
replaced
396:a71fcc27f231 | 397:6148e9063069 |
---|---|
215 | 215 |
216 | 216 |
217 class RadioColPanel(HorizontalPanel, ClickHandler): | 217 class RadioColPanel(HorizontalPanel, ClickHandler): |
218 | 218 |
219 def __init__(self, parent, referee, player_nick, players, queue_data): | 219 def __init__(self, parent, referee, player_nick, players, queue_data): |
220 """ | |
221 @param parent | |
222 @param referee | |
223 @param player_nick | |
224 @param players | |
225 @param queue_data: list of integers (queue to start, queue limit) | |
226 """ | |
220 # We need to set it here and not in the CSS :( | 227 # We need to set it here and not in the CSS :( |
221 HorizontalPanel.__init__(self, Height="90px") | 228 HorizontalPanel.__init__(self, Height="90px") |
222 ClickHandler.__init__(self) | 229 ClickHandler.__init__(self) |
223 self._parent = parent | 230 self._parent = parent |
224 self.referee = referee | 231 self.referee = referee |
238 self.current_player = None | 245 self.current_player = None |
239 for player in self.players: | 246 for player in self.players: |
240 self.add(player) | 247 self.add(player) |
241 self.addClickListener(self) | 248 self.addClickListener(self) |
242 | 249 |
243 help_msg = HTML("""Accepted file formats: Ogg Vorbis (recommended), MP3.<br /> | 250 help_msg = """Accepted file formats: Ogg Vorbis (recommended), MP3.<br /> |
244 Please do not submit files that are protected by copyright.<br /> | 251 Please do not submit files that are protected by copyright.<br /> |
245 Click <a style="color: red;">here</a> if you need some support :) | 252 Click <a style="color: red;">here</a> if you need some support :)""" |
246 """) | 253 link_cb = lambda: self._parent.host.bridge.call('joinMUC', None, DEFAULT_MUC, self._parent.nick) |
247 help_msg.setStyleName('chatTextInfo-link') | 254 self._parent.printInfo(help_msg, type_='link', link_cb=link_cb) |
248 help_msg.addClickListener(lambda: self._parent.host.bridge.call('joinMUC', None, DEFAULT_MUC, self._parent.nick)) | |
249 self._parent.content.add(help_msg) | |
250 | 255 |
251 def pushNextSong(self, title): | 256 def pushNextSong(self, title): |
252 """Add a song to the left panel's next songs queue""" | 257 """Add a song to the left panel's next songs queue""" |
253 next_song = Label(title) | 258 next_song = Label(title) |
254 next_song.setStyleName("radiocol_next_song") | 259 next_song.setStyleName("radiocol_next_song") |
271 for player in self.players: | 276 for player in self.players: |
272 if player.timestamp == timestamp: | 277 if player.timestamp == timestamp: |
273 return False | 278 return False |
274 return True | 279 return True |
275 | 280 |
276 def radiocolPreload(self, timestamp, filename, title, artist, album): | 281 def radiocolPreload(self, timestamp, filename, title, artist, album, sender): |
277 if not self.radiocolCheckPreload(timestamp): | 282 if not self.radiocolCheckPreload(timestamp): |
278 return # song already preloaded | 283 return # song already preloaded |
279 preloaded = False | 284 preloaded = False |
280 for player in self.players: | 285 for player in self.players: |
281 if not player.filename or \ | 286 if not player.filename or \ |
284 #we use it to preload the next one | 289 #we use it to preload the next one |
285 player.preload(timestamp, filename, title, artist, album) | 290 player.preload(timestamp, filename, title, artist, album) |
286 preloaded = True | 291 preloaded = True |
287 break | 292 break |
288 if not preloaded: | 293 if not preloaded: |
289 print("WARNING: Can't preload song, we are getting too many songs to preload, we shouldn't have more than 2 at once") | 294 print(_("WARNING: Can't preload song, we are getting too many songs to preload, we shouldn't have more than %d at once") % self.queue_data[1]) |
290 else: | 295 else: |
291 self.pushNextSong(title) | 296 self.pushNextSong(title) |
297 self._parent.printInfo(_('%(user)s uploaded %(artist)s - %(title)s') % {'user': sender, 'artist': artist, 'title': title}) | |
292 | 298 |
293 def radiocolPlay(self, filename): | 299 def radiocolPlay(self, filename): |
294 found = False | 300 found = False |
295 for player in self.players: | 301 for player in self.players: |
296 if not found and player.filename == filename: | 302 if not found and player.filename == filename: |