# Copyright (c) 2007 Jurgen Scheible # volume control, use up and down arrow keys to lower or increase the volume import appuifw, key_codes, e32, audio S = audio.Sound.open("E:\\Python\\midi\\volsound.mid") def playsound(): S.play(30,0) def VolUp(): highest = S.max_volume() current = S.current_volume() if current < highest: volume = current + highest/10 S.set_volume(volume) def VolDown(): highest = S.max_volume() current = S.current_volume() if current > 0: volume = current - highest/10 S.set_volume(volume) def keys(event): if event['keycode'] == key_codes.EKeyUpArrow: VolUp() if event['keycode'] == key_codes.EKeyDownArrow: VolDown() def quit(): S.stop() S.close() app_lock.signal() appuifw.app.set_exit() appuifw.app.body = canvas =appuifw.Canvas(event_callback=keys) appuifw.app.title = u"Volume control" appuifw.app.exit_key_handler = quit playsound() app_lock = e32.Ao_lock() app_lock.wait()