Mercurial > libervia-web
annotate browser_side/radiocol.py @ 275:a763b2ac5d41
bridge + browser_side: bridge signals for games and their callbacks:
- added radiocolPlayers and tarotGamePlayers to get the list of players
- added roomLeft to remove the muc from the host's room list
- display symbols to identify the players in a muc
- factorization of ChatPanel.startGame
author | souliane <souliane@mailoo.org> |
---|---|
date | Thu, 21 Nov 2013 16:13:14 +0100 |
parents | 63e9b680d3e7 |
children | 0eba1c4f9c6f |
rev | line source |
---|---|
127 | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | |
3 | |
4 """ | |
5 Libervia: a Salut à Toi frontend | |
165 | 6 Copyright (C) 2011, 2012, 2013 Jérôme Poisson <goffi@goffi.org> |
127 | 7 |
8 This program is free software: you can redistribute it and/or modify | |
9 it under the terms of the GNU Affero General Public License as published by | |
10 the Free Software Foundation, either version 3 of the License, or | |
11 (at your option) any later version. | |
12 | |
13 This program is distributed in the hope that it will be useful, | |
14 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 GNU Affero General Public License for more details. | |
17 | |
18 You should have received a copy of the GNU Affero General Public License | |
19 along with this program. If not, see <http://www.gnu.org/licenses/>. | |
20 """ | |
21 | |
243
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
165
diff
changeset
|
22 import pyjd # this is dummy in pyjs |
127 | 23 from pyjamas.ui.VerticalPanel import VerticalPanel |
24 from pyjamas.ui.HorizontalPanel import HorizontalPanel | |
25 from pyjamas.ui.SimplePanel import SimplePanel | |
129
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
26 from pyjamas.ui.FlexTable import FlexTable |
127 | 27 from pyjamas.ui.FormPanel import FormPanel |
28 from pyjamas.ui.NamedFrame import NamedFrame | |
29 from pyjamas.ui.FileUpload import FileUpload | |
30 from pyjamas.ui.Label import Label | |
31 from pyjamas.ui.Button import Button | |
32 from pyjamas.ui.ClickListener import ClickHandler | |
33 from pyjamas.ui.MouseListener import MouseHandler | |
128 | 34 from pyjamas.ui.Hidden import Hidden |
35 from pyjamas.ui.HTML import HTML | |
127 | 36 from pyjamas import Window |
129
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
37 from pyjamas.Timer import Timer |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
38 from __pyjamas__ import JS |
127 | 39 |
40 from jid import JID | |
41 from tools import html_sanitize | |
42 | |
43 | |
129
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
44 class MetadataPanel(FlexTable): |
127 | 45 |
46 def __init__(self): | |
129
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
47 FlexTable.__init__(self) |
243
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
165
diff
changeset
|
48 title_lbl = Label("title:") |
129
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
49 title_lbl.setStyleName('radiocol_metadata_lbl') |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
50 artist_lbl = Label("artist:") |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
51 artist_lbl.setStyleName('radiocol_metadata_lbl') |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
52 album_lbl = Label("album:") |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
53 album_lbl.setStyleName('radiocol_metadata_lbl') |
243
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
165
diff
changeset
|
54 self.title = Label("") |
129
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
55 self.title.setStyleName('radiocol_metadata') |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
56 self.artist = Label("") |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
57 self.artist.setStyleName('radiocol_metadata') |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
58 self.album = Label("") |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
59 self.album.setStyleName('radiocol_metadata') |
243
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
165
diff
changeset
|
60 self.setWidget(0, 0, title_lbl) |
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
165
diff
changeset
|
61 self.setWidget(1, 0, artist_lbl) |
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
165
diff
changeset
|
62 self.setWidget(2, 0, album_lbl) |
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
165
diff
changeset
|
63 self.setWidget(0, 1, self.title) |
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
165
diff
changeset
|
64 self.setWidget(1, 1, self.artist) |
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
165
diff
changeset
|
65 self.setWidget(2, 1, self.album) |
129
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
66 self.setStyleName("radiocol_metadata_pnl") |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
67 |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
68 def setTitle(self, title): |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
69 self.title.setText(title) |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
70 |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
71 def setArtist(self, artist): |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
72 self.artist.setText(artist) |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
73 |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
74 def setAlbum(self, album): |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
75 self.album.setText(album) |
127 | 76 |
243
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
165
diff
changeset
|
77 |
127 | 78 class ControlPanel(FormPanel): |
79 """Panel used to show controls to add a song, or vote for the current one""" | |
80 | |
128 | 81 def __init__(self, referee): |
127 | 82 FormPanel.__init__(self) |
129
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
83 self._timer = Timer(notify=self._timeCb) |
127 | 84 self.setEncoding(FormPanel.ENCODING_MULTIPART) |
85 self.setMethod(FormPanel.METHOD_POST) | |
151
a159cc29b556
server side: file upload is now more generic:
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
86 self.setAction("upload_radiocol") |
127 | 87 vPanel = VerticalPanel() |
88 | |
89 hPanel = HorizontalPanel() | |
90 hPanel.setSpacing(5) | |
130 | 91 self.file_upload = FileUpload() |
92 self.file_upload.setName("song") | |
93 hPanel.add(self.file_upload) | |
127 | 94 |
130 | 95 self.upload_btn = Button("Upload song", getattr(self, "onBtnClick")) |
96 hPanel.add(self.upload_btn) | |
127 | 97 |
129
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
98 self.status = Label() |
130 | 99 hPanel.add(self.status) |
129
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
100 |
127 | 101 vPanel.add(hPanel) |
243
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
165
diff
changeset
|
102 |
128 | 103 #We need to know the referee |
104 referee_field = Hidden('referee', referee) | |
105 vPanel.add(referee_field) | |
127 | 106 |
107 self.add(vPanel) | |
108 self.addFormHandler(self) | |
243
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
165
diff
changeset
|
109 |
129
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
110 def _timeCb(self, timer): |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
111 self.status.setText('') |
127 | 112 |
113 def onBtnClick(self): | |
114 self.submit() | |
243
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
165
diff
changeset
|
115 |
127 | 116 def onSubmit(self, event): |
117 pass | |
118 | |
130 | 119 def blockUpload(self): |
120 self.file_upload.setVisible(False) | |
121 self.upload_btn.setEnabled(False) | |
122 | |
123 def unblockUpload(self): | |
124 self.file_upload.setVisible(True) | |
125 self.upload_btn.setEnabled(True) | |
126 | |
127 | 127 def onSubmitComplete(self, event): |
128 result = event.getResults() | |
129 if result == "OK": | |
130 | 130 self.status.setText('[Your song has been added to queue]') |
129
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
131 self.status.setStyleName('radiocol_upload_status_ok') |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
132 self._timer.schedule(5000) |
127 | 133 elif result == "KO": |
130 | 134 self.status.setText('[Something went wrong during your song upload]') |
129
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
135 self.status.setStyleName('radiocol_upload_status_ko') |
127 | 136 else: |
137 Window.alert('Submit error: %s' % result) | |
138 | |
243
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
165
diff
changeset
|
139 |
129
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
140 class Player(HTML): |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
141 |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
142 def __init__(self, player_id, metadata_panel): |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
143 HTML.__init__(self) |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
144 self._id = player_id |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
145 self.metadata = metadata_panel |
243
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
165
diff
changeset
|
146 self.title = "" |
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
165
diff
changeset
|
147 self.artist = "" |
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
165
diff
changeset
|
148 self.album = "" |
129
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
149 self.filename = None |
243
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
165
diff
changeset
|
150 self.played = False # True when song is playing/played, become False on preload |
129
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
151 |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
152 def preload(self, filename, title, artist, album): |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
153 """preload the song but doesn't play it""" |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
154 self.filename = filename |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
155 self.title = title |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
156 self.artist = artist |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
157 self.album = album |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
158 self.played = False |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
159 self.setHTML('<audio id="%s" style="display: none" preload="auto" src="radiocol/%s" />' % (self._id, html_sanitize(filename))) |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
160 print "preloading %s in %s" % (title, self._id) |
243
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
165
diff
changeset
|
161 |
129
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
162 def play(self): |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
163 """actually play the song""" |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
164 self.played = True |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
165 self.metadata.setTitle(self.title) |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
166 self.metadata.setArtist(self.artist) |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
167 self.metadata.setAlbum(self.album) |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
168 |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
169 JS(""" |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
170 var player = top.document.getElementById(this._id); |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
171 player.play(); |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
172 """) |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
173 |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
174 |
127 | 175 class RadioColPanel(HorizontalPanel, ClickHandler): |
176 | |
275
a763b2ac5d41
bridge + browser_side: bridge signals for games and their callbacks:
souliane <souliane@mailoo.org>
parents:
243
diff
changeset
|
177 def __init__(self, parent, referee, player_nick, players=None): |
127 | 178 HorizontalPanel.__init__(self) |
179 ClickHandler.__init__(self) | |
180 self._parent = parent | |
181 self.referee = referee | |
182 self.setStyleName("radiocolPanel") | |
129
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
183 self.setHeight('30%') |
243
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
165
diff
changeset
|
184 |
127 | 185 # Now we set up the layout |
186 self.left_panel = VerticalPanel() | |
129
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
187 self.left_panel.setStyleName("radiocol_left_panel") |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
188 self.left_panel.setHeight('100%') |
127 | 189 self.add(self.left_panel) |
128 | 190 self.right_panel = VerticalPanel() |
127 | 191 self.metadata_panel = MetadataPanel() |
128 | 192 self.right_panel.add(self.metadata_panel) |
193 self.control_panel = ControlPanel(self.referee) | |
194 self.right_panel.add(self.control_panel) | |
127 | 195 self.add(self.right_panel) |
128 | 196 #self.right_panel.setBorderWidth(1) |
130 | 197 self.next_songs = [] |
129
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
198 self.players = [Player("player_%d" % i, self.metadata_panel) for i in range(4)] |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
199 self.current_player = None |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
200 for player in self.players: |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
201 self.right_panel.add(player) |
127 | 202 self.addClickListener(self) |
130 | 203 |
204 def pushNextSong(self, title): | |
205 """Add a song to the left panel's next songs queue""" | |
206 next_song = Label(title) | |
207 next_song.setStyleName("radiocol_next_song") | |
208 self.next_songs.append(next_song) | |
209 self.left_panel.append(next_song) | |
210 | |
211 def popNextSong(self): | |
212 """Remove the first song of next songs list | |
213 should be called when the song is played""" | |
214 #FIXME: should check that the song we remove is the one we play | |
215 next_song = self.next_songs.pop(0) | |
216 self.left_panel.remove(next_song) | |
243
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
165
diff
changeset
|
217 |
128 | 218 def radiocolPreload(self, filename, title, artist, album): |
129
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
219 preloaded = False |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
220 for player in self.players: |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
221 if not player.filename or \ |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
222 (player.played and player != self.current_player): |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
223 #if player has no file loaded, or it has already played its song |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
224 #we use it to preload the next one |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
225 player.preload(filename, title, artist, album) |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
226 preloaded = True |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
227 break |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
228 if not preloaded: |
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
229 print("WARNING: Can't preload song, we are getting too many songs to preload, we shouldn't have more than 2 at once") |
130 | 230 else: |
231 self.pushNextSong(title) | |
243
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
165
diff
changeset
|
232 |
130 | 233 def radiocolPlay(self, filename): |
234 for player in self.players: | |
235 if player.filename == filename: | |
236 player.play() | |
237 self.popNextSong() | |
238 self.current_player = player | |
239 return | |
240 print("WARNING: Song not found in queue, can't play it. This should not happen") | |
127 | 241 |
130 | 242 def radiocolNoUpload(self): |
243 self.control_panel.blockUpload() | |
129
dd0d39ae7d24
RadioCol: song preloading + fonctionnal players
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
244 |
130 | 245 def radiocolUploadOk(self): |
246 self.control_panel.unblockUpload() | |
247 | |
248 def radiocolSongRejected(self, reason): | |
249 Window.alert("Song rejected: %s" % reason) |