View Single Post
  #2  
Old 03-07-2010, 10:13 PM
IGoudt IGoudt is offline
Member
 
Join Date: Sep 2009
Posts: 20
I would make use of a variable 'audioPlaying = True/False' that's being checked everytime a key-event occurs.

snippets: (I use self here since I think in classes/objects)

Code:
def playAudio(self, file):
self.audioPlaying = True
..code to start audio
Code:
def onkeydown(self, key):
if not self.audioPlaying:
 ... handle keys
else:
     print "audio playing, so keys are disabled"
in the place where you register onkeydown, register the following:
Code:
viz.callback(viz.MEDIA_END, self.audioEnded)

def audioEnded(self, e):
     self.audioPlaying = False
Reply With Quote