I am trying to create a listbox using canvas. My requirement is when i scroll through the menu items (which are just images) it should play audio files of about 20 secs. But I am not able to interrupt the audio when I am scrolling down quickly. Here is the code I wrote:
import appuifw, graphics, e32
count = 0
y = 0
sound = 0
snd_lock = e32.Ao_lock()
c.blit(bg,target=(0,y)) #acts as navigation bar
c = appuifw.Canvas(event_callback=None, redraw_callback=handle_redraw)
def sound_callback(prev_state, current_state, err):
if current_state == audio.EOpen:
while sound.state() == 1: #plays the sound file only if file is open
sound.play(callback = sound_callback)
sound = audio.Sound.open("aud.mp3")
if sound != 0 and sound.state() == 2: #checks if an audio is playing
if count == 1:
elif count == 2:
As far as I am considered this should work fine. But when I press down when the first audio is playing it will scroll down but the next audio is not playing and after scrolling down to 2 menu items application will close off.
Can somebody help me???
Hope to get a reply as soon as possible.