konto usunięte

Temat: SL4A i Timer - problem

Witam,

mam taki problem.
Jest program na Androida napisany w pythonie z pomocą SL4A.

Mam klasę realizującą coś na wzór timera:


class TimerClass(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.event = threading.Event()

def run(self):
while not self.event.is_set():
print droid.mediaPlayInfo(currFile);
self.event.wait(1)

def stop(self):
self.event.set()


i pętle czekającą na zdarzenie (tutaj oprogramowane są użyte przyciski)


def eventloop():
while True:
event=droid.eventWait().result
#print event
if event["name"]=="click":
iid=event["data"]["id"]
if iid=="button1":
global currFile
currFile = mylist[int(droid.fullQueryDetail("spinner1").result['selectedItemPosition'])]
tmr.stop()
for title in mylist:
if droid.mediaIsPlaying(title).result:
droid.mediaPlayPause(title)
if droid.mediaPlayStart(currFile):
tmr.start()
elif iid=="button3":
tmr.stop()
return
elif iid=="button2":
tmr.stop()
droid.mediaPlayPause(currFile);
elif event["name"]=="screen":
if event["data"]=="destroy":
return


i teraz uruchamiany jest program...
wybierana jest piosenka
i zaczyna sobie grać..
w tym czasie uruchamiany jest tmr.start()
wczesniej stworzony obiek tmr = TimerClass()

i do tego momentu wszystko działa jak trzeba. Co sekunde pojawia mi się informacja o kawałku który jest wlasnie odtwarzany..

Ale od teraz koniec..nie ma reakcji na zaden przycisk
np. pauza
tmr.stop()
droid.mediaPlayPause(currFile)

w teorii powinna zatrzymać wyswietlanie informacji i zapauzować piosenkę..

Ktoś może mi wyjaśnić dlaczego ?

Skoro wątek działa niezależnie to dlaczego tmr.stop() nie zatrzymuje go.
Wygląda to tak jakby w ogole program nie wiedział , że naciśnięto przycisk...Ten post został edytowany przez Autora dnia 08.05.14 o godzinie 09:25