Based on the example given in the "Mobile Python" book (simply amazing book btw), i've managed to get my application to open and play a .wav file until it finishes, by using the sound callback function. What I'm trying to do now is initiate the act of playing the sound inside a NEW thread, so my main thread can continue its execution without being held by the Ao_lock(). This is what I've done so far, I try opening the audio file and then pass the open handler to a new thread, and I've included the sound_callback function as a nested function inside my threaded one, so that it has access to the sound_lock object (no race condition, i hope!). But, it doesn't seem to get past the "here in the beginning" point... does anyone have an idea what might be going wrong?
Thnx in advance!!
sound_lock = e32.Ao_lock()
def sound_callback(prev_state, current_state, err):
print "here in the middle"
if current_state == audio.EOpen:
print "here at the beginning"
sound.play(callback = sound_callback)
print "here at the end"
sound_file = SOUNDS_PATH + file_name + ".wav"
sound = audio.Sound.open(sound_file)
thread.start_new_thread(sound_thread, (sound, ))