Hi, I want to create a python wrapper for mplayer, which will read subtitles for movies through speech dispatcher. It is mainly for visually impaired people like me. I am using mplayer.py module for controlling mplayer in slave mode and pysub module for accessing .srt files. I want to create simple ncurses interface, which will just wait for certain keyboard shortcuts for quitting, pausing, stopping, changing of voice rate etc. But now how to do this? I have two loops: curses waiting for keypresses and another waiting for right time, mplayer for the time of movie. I have put the second loop into thead and it looks like this: class threadsub(threading.Thread): def __init__(self): super(threadsub, self).__init__() self._stop = threading.Event() def stop(self): self._stop.set() def stopped(self): return self._stop.isSet() def run(self): global playing for i in range (0, len(subs) - 1): ms = float(subs[i].start.milliseconds) ms = round(ms / 1000,1) time = subs[i].start.hours * 3600 + subs[i].start.minutes * 60 + subs[i].start.seconds + ms while playing == True: if time == round(p.time_pos,1): s.speak(subs[i].text) break if self.stopped() == True: playing = False if self.stopped() == True: break When i exit the program, i end curses and call threadsub.stop() But it doesn't stop, nor it raises an error. Can you please gi me an advice, how to do this properly? Or can you suggest other method for achieving this? Forgive my possible mistakes when pasting code, I am posting something like this for the first time. Thank you.
Bookmarks