Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Sep 2004

    top tip (for n95 and similar) and request....

    Hi All,

    I have just started learning Python today on my n95 and am enjoying it so far.

    I was very frustrated by creating a file, sending it over, running it etc. and couldnt get the pushtools thing to work but I found the ultimate solution.

    There is a product called symsmb (shareware) which lets you map a folder on the mobile to a standard windows share

    I can now access the py files in my e:\python folder directly on the PC via wifi. this would even work with linux and mac.

    thats my tip, and now my question.

    I am trying to create a simple app that lists all the mp3 files in a folder and plays them, I have the list thing working but not the playing part.

    the code is this

    # this script lets you read the content of the image directory
    # and displays the results in a selection list (UI)
    import appuifw
    import e32
    import os
    import audio
    def playsound(fn):
        S = audio.Sound.open('e:\\python\'+fn)
    # drefine the directory to read
    # read the directory
    # put the found items of the directory in to a selction list for showing them on the screen
    # show the slected item 
    print files[index]
    firstly this doesnt work any ideas why?
    secondly how can I filter the list to only show *.mp3 ?

    Thanks for any and all help!!!

  2. #2
    Super Contributor
    Join Date
    Oct 2007
    Deva, Romania

    Re: top tip (for n95 and similar) and request....


    In order to show only mp3 files, filter the files like this:
    for f in os.listdir(folder):
            if(f.endswith('.mp3')):print f
    The example above checks the ending of each file for the extension ".mp3" and prints the names of the corresponding ones. For more information about working with files and folders, see this article.

    As for playing the music files, I believe the problem is with the single final slash in S = audio.Sound.open('e:\\python\'+fn). I got an "invalid token error", but after adding a second slash ('e:\\python\\'+fn) it seems to work. Is that the problem you're facing?
    Last edited by bogdan.galiceanu; 2008-06-04 at 20:14.

Posting Permissions

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