×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Apr 2012
    Posts
    6

    Unhappy How to Play any Audio when up & down arrow is being pressed

    Hi...

    I've been trying to play an audio when up arrow is pressed,but not getting the obtained result. I tried with simple thing i'e to print any message when any key is presses, i'm able to do this but how to I play an Audio file when up and down arrow keys are pressed.
    Please help me.


    Regards
    Ashwini

  2. #2
    Registered User
    Join Date
    Apr 2012
    Posts
    6

    Re: How to Play any Audio when up & down arrow is being pressed

    import appuifw, e32, key_codes
    import audio


    def up():
    s=audio.Sound.open(u"Var.mp3")
    s.play()

    def quit():
    app_lock.signal()


    canvas = appuifw.Canvas()
    appuifw.app.body = canvas
    canvas.bind(key_codes.EKeyUpArrow, up)

    appuifw.app.exit_key_handler = quit
    app_lock = e32.Ao_lock()
    app_lock.wait()


    This is the code I tried for above application, but still i'm not able to play the audio file.

  3. #3
    Regular Contributor
    Join Date
    Nov 2009
    Posts
    200

    Re: How to Play any Audio when up & down arrow is being pressed

    There nothing else wrong than your file path must be wrong. Does "Var.mp3" exist in the same directory than your python script? Even if it does try to write the whole file path.

    edit:
    Other option is that your phone has the "wrong" up arrow. I actually tested your script on E7 and there your keycode "EKeyUpArrow" is a match for hw-keyboard up arrow. What phone are you testing this with?

  4. #4
    Registered User
    Join Date
    Apr 2012
    Posts
    6

    Re: How to Play any Audio when up & down arrow is being pressed

    Hey thanks for ur reply...
    My code did work fine..I'd to initialise the sound.here it is

    import appuifw, key_codes, e32
    import audio

    def keys(event):
    global sound
    if event ['keycode'] == key_codes.EKeyUpArrow:
    appuifw.note(u"Up arrow was pressed")
    sound = audio.Sound.open(u"ahelp.mp3")
    sound.play()
    elif event ['keycode'] == key_codes.EKeyDownArrow:
    appuifw.note(u"Down arrow was pressed")
    sound = audio.Sound.open(u"Var.mp3")
    sound.play()
    sound = 0


    def quit():
    app_lock.signal()

    canvas = appuifw.Canvas(event_callback = keys)
    appuifw.app.body = canvas
    appuifw.app.exit_key_handler = quit
    app_lock = e32.Ao_lock()
    app_lock.wait()

  5. #5
    Regular Contributor
    Join Date
    Nov 2009
    Posts
    200

    Re: How to Play any Audio when up & down arrow is being pressed

    So the problem is solved?

  6. #6
    Registered User
    Join Date
    Sep 2011
    Posts
    29

    Re: How to Play any Audio when up & down arrow is being pressed

    yeah it is solved..thank u

Similar Threads

  1. Replies: 5
    Last Post: 2010-06-04, 10:28
  2. Why can't i see griditems until the arrow key is pressed?
    By kingjim in forum Symbian User Interface
    Replies: 4
    Last Post: 2008-12-21, 03:20
  3. Using Audio Proxy Server to play only (not play and record)
    By rob_savageminds in forum Symbian Media (Closed)
    Replies: 7
    Last Post: 2007-09-04, 12:11
  4. Setfocus when user pressed up/down arrow keys (6600)
    By patilmmilind in forum Symbian User Interface
    Replies: 9
    Last Post: 2006-11-21, 09:49

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×