115 |
self.stopped = True |
self.stopped = True |
116 |
print "[TodicPlayer] : stopped" |
print "[TodicPlayer] : stopped" |
117 |
url = __backend__ + "&action=playbacktime&subaction=stopped&time=" + str( self.playingPosition ) |
url = __backend__ + "&action=playbacktime&subaction=stopped&time=" + str( self.playingPosition ) |
118 |
open_url(url) |
open_url_safe(url) |
119 |
|
|
120 |
|
|
121 |
def onPlayBackEnded(self): |
def onPlayBackEnded(self): |
122 |
self.stopped = True |
self.stopped = True |
123 |
print "[TodicPlayer] : ended" |
print "[TodicPlayer] : ended" |
124 |
url = __backend__ + "&action=playbacktime&subaction=ended&time=" |
url = __backend__ + "&action=playbacktime&subaction=ended&time=" |
125 |
open_url(url) |
open_url_safe(url) |
126 |
|
|
127 |
def tick(self): |
def tick(self): |
128 |
if ( self.isPlaying() ): |
if ( self.isPlaying() ): |
129 |
self.playingPosition = self.getTime() |
self.playingPosition = self.getTime() |
130 |
now = time() |
now = time() |
131 |
#print "[Todic] tick " + str(now) + " " + str(self.lastReport) + " : " +str(now - self.lastReport) |
#print "[Todic] tick " + str(now) + " " + str(self.lastReport) + " : " +str(now - self.lastReport) |
137 |
|
|
138 |
def reportPlaytime(self): |
def reportPlaytime(self): |
139 |
url = __backend__ + "&action=playbacktime&subaction=playing&time=" + str( self.playingPosition ) |
url = __backend__ + "&action=playbacktime&subaction=playing&time=" + str( self.playingPosition ) |
140 |
open_url(url) |
open_url_safe(url) |
141 |
print "[Todic] reportPlaytime:" + url |
print "[Todic] reportPlaytime:" + url |
142 |
|
|
143 |
|
|
162 |
return nodelist[0].childNodes[0].nodeValue |
return nodelist[0].childNodes[0].nodeValue |
163 |
|
|
164 |
|
|
165 |
|
|
166 |
def SaveFile(path, data): |
def SaveFile(path, data): |
167 |
file = open(path, 'w') |
file = open(path, 'w') |
168 |
file.write(data) |
file.write(data) |
169 |
file.close() |
file.close() |
170 |
|
|
171 |
|
|
172 |
|
|
173 |
def open_url(url): |
def open_url(url): |
174 |
req = urllib2.Request(url) |
req = urllib2.Request(url) |
175 |
content = urllib2.urlopen(req) |
content = urllib2.urlopen(req) |
178 |
return data |
return data |
179 |
|
|
180 |
|
|
181 |
|
# wraps open url in a catch-all exception handler |
182 |
|
# usefull for periodic back-reporting that should not interrupt the program flow |
183 |
|
def open_url_safe(url): |
184 |
|
try: |
185 |
|
return open_url(url) |
186 |
|
except: |
187 |
|
print "Some error during open_url call to ", url |
188 |
|
|
189 |
|
|
190 |
|
|
191 |
def rootMenu(): |
def rootMenu(): |
192 |
|
|
193 |
msg = open_url(__backend__ + "&action=messages") |
msg = open_url(__backend__ + "&action=messages") |