×

Discussion Board

Results 1 to 11 of 11

Thread: audio.sound

  1. #1
    Registered User
    Join Date
    Oct 2007
    Location
    Brasil
    Posts
    39

    Question audio.sound

    hello

    I am writing the following line to format the hour, but is not working. appreciate if anyone can help me.


    sound = audio.Sound.open(filename)
    sound.play(callback = sound_callback)
    duracao = time.strftime("%M:%S",time.localtime(sound.duration()))

    print duracao

  2. #2
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: audio.sound

    Hi,

    How is it not working? Does it throw an error? Does it do nothing? Does is display a wrong result? We can't help if you don't give us the details.

  3. #3
    Registered User
    Join Date
    Oct 2007
    Location
    Brasil
    Posts
    39

    Re: audio.sound

    That's what I'm getting:

    audio.Sound.open sound = (filename)
    sound.play (callback = sound_callback)

    x = sound.duration()

    print x

    >>> 153492872

    x = time.strftime ("% M:% S", time.localtime (sound.duration ()))

    print x

    >>> 54:32

  4. #4
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: audio.sound

    The PyS60 documentation says this:
    duration()
    Returns the duration of the file in microseconds.
    So, x is microseconds, not seconds. If you do x = time.strftime ("% M:% S", time.localtime(sound.duration() / 1000000)) you should get the correct result.

  5. #5
    Registered User
    Join Date
    Oct 2007
    Location
    Brasil
    Posts
    39

    Re: audio.sound

    thanks for the tip

  6. #6
    Registered User
    Join Date
    Oct 2007
    Location
    Brasil
    Posts
    39

    Re: audio.sound

    ok. worked ... but now I am in error in the following line

    path = u "e: \ \ Sounds \ \ Simple \ \ só podia ser com você.mp3"
    files = map (unicode, os.listdir (path))

    >>> UnicodeError: ASCII decoding error: ordinal not in range (128)
    Last edited by aldosilva; 2010-11-22 at 15:14.

  7. #7
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: audio.sound

    Before we get into the string encoding issues, what are you trying to do? os.listdir can be called on directories only. Your path points to an mp3 file...

    Also, why are you using those spaces in the path string? I don't know how your files and directories are named but I'm pretty sure that might also cause some problems.

  8. #8
    Registered User
    Join Date
    Oct 2007
    Location
    Brasil
    Posts
    39

    Re: audio.sound

    I believe the problem is in the accent used in Portuguese.
    If I remove accents (So podia ser com voce.mp3). I can read normally.
    As for the disregard spaces ...

  9. #9
    Registered User
    Join Date
    Oct 2007
    Location
    Brasil
    Posts
    39

    Re: audio.sound

    after reading some articles on the internet I got the following line of code


    path = u "e: \ \ Sounds \ Digital \ \"
    os.chdir (path)
    files = os.listdir (u '. ")
    x = len (files)



    with that I can read the files (mp3) of the directory, including those with special characters (á, é, ü, ä, ü, ç, etc.). however ...


    [I] track path = files
    audio.Sound.open sound = (path)



    At this point the application to when it encounters a file that has special characters in name (ç, á, é, etc.). that is, if we consider the following list of files


    1 - Anywhere
    2 - Dream On
    3 - Just a little bit
    4 - Chão de giz
    5 - Só nos resta viver
    6 - Opium Trail
    7 - We Have Heaven


    Only items 1, 2, 3 are run.

    Someone could tell me what to do to solve this problem.
    aldo silva
    ---------------------------
    http://www.inphormatica.com

  10. #10
    Registered User
    Join Date
    Mar 2011
    Posts
    44

    Re: audio.sound

    Hi

    what does the error "Function object has no attribute Sound" means?

    I have written a script like this:

    def snd():
    global soundn
    soundn = audio.Sound.open("hi.mp3")

    def playMP3():
    global soundn
    soundn.play()
    e32.ao_sleep( 1 )


    snd()
    playMP3()

    It was working fine when i installed after packaging using application packager.But when I installed it in my phone after open signing it throws out the above error.I dont know what to do

    Regards
    Simil
    Last edited by Simil Susan; 2011-04-02 at 03:48.

  11. #11
    Registered User
    Join Date
    Mar 2011
    Posts
    44

    Re: audio.sound

    I found the bug..it is working fine now.

Similar Threads

  1. play many audio sound one after another
    By m.alsheikh in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2010-03-22, 17:40
  2. How to compare 2 audio sound?
    By joseph.m in forum Audio
    Replies: 4
    Last Post: 2009-04-03, 06:30
  3. audio.Sound.open not work
    By zy82518 in forum Symbian
    Replies: 7
    Last Post: 2007-07-24, 20:56
  4. Inquiry regarding audio/sound
    By pvm_lee in forum Symbian Tools & SDKs
    Replies: 4
    Last Post: 2005-11-19, 08:10
  5. Inquiry regarding audio/sound for s60 2.1
    By pvm_lee in forum Symbian Media (Closed)
    Replies: 0
    Last Post: 2005-11-17, 22:44

Posting Permissions

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