You Are Here:

Community: Developer Discussion Boards

#1 Old Unable to open file for playing, but opens otherwise - 2008-09-25, 12:06

Join Date: Aug 2008
Posts: 87
ra.ravi.rav
Offline
Regular Contributor
I have the follwing code, which is a simple mp3 player, I am running it on Nokia 7610 (S60 2ndEd FP1):

Code:
import appuifw, e32, audio, sys

song = None
curr_pos = 0

def play():
    s = appuifw.query(u"Path", "text")
    print s
    song = open(s)
    song.play()

def pause():
    curr_pos = song.current_position()
    song.stop

def stop():
    song.stop()

def exit():
    exit = appuifw.query(u"You want to exit?", "query")
    if exit:
        sys.exit(0)
    else:
        pass


if __name__ == '__main__':
    appuifw.app.menu = [(u"Play", play), (u"Pause", pause), (u"Stop", stop)]
    appuifw.app.exit_key_handler = exit
    appuifw.app.title = u"FooMP3"
    app_lock = e32.Ao_lock()
    app_lock.wait()
On choosing play menu, I enter the filename as "E:\\Sounds\\song.mp3" and get the error as:

Code:
Traceback (most recent call last):
  File "E:\System\Apps\Python\my\mp3player.py", line 9, in play
    song = audio.Sound.open(s)
  File "E:\system\libs\audio.py", line 44, in open
    raise SymbianError,(callback_error[0],
SymbianError: [Errno -28] Error opening file: KErrBadName
However if I try to open thr file usin normal open() call it works soomthly as:

Code:
str = appuifw.query(u"Enter file path", "text", "E:\\Sounds\\song.mp3")
f = open(str)
print dir(f)
What may be the possible reason?
Reply With Quote

#2 Old Re: Unable to open file for playing, but opens otherwise - 2008-09-25, 12:25

Join Date: Aug 2008
Posts: 87
ra.ravi.rav
Offline
Regular Contributor
I got the solution:

enetring "E:\\Sounds\\song.mp3" translates as "E:\\\\Sounds\\\\song.mp3" by appuifw.query() function.
Reply With Quote

#3 Old Re: Unable to open file for playing, but opens otherwise - 2008-09-25, 13:40

Join Date: Jul 2008
Posts: 103
ck.umraliya's Avatar
ck.umraliya
Offline
Forum Nokia Champion
hi ra.ravi.rav

Instead of entering the full path each time,
you can find out all mp3 files on the phone.
Go through this article.

Regards,
Chintan
Reply With Quote

#4 Old Re: Unable to open file for playing, but opens otherwise - 2008-09-25, 14:49

Join Date: Aug 2008
Posts: 87
ra.ravi.rav
Offline
Regular Contributor
Thanks for your reply. Adding autosearch was indeed the next job on the list.
Reply With Quote

#5 Old Re: Unable to open file for playing, but opens otherwise - 2008-09-25, 15:13

Join Date: May 2007
Posts: 2,739
Location: 21.46 N 72.11 E
croozeus's Avatar
croozeus
Offline
Forum Nokia Champion
Quote:
Originally Posted by ra.ravi.rav View Post
I got the solution:

enetring "E:\\Sounds\\song.mp3" translates as "E:\\\\Sounds\\\\song.mp3" by appuifw.query() function.
Rather enter "E:\Sounds\song.mp3" in the appuifw.query which would be manipulated to the correct path i.e. "E:\\Sounds\\song.mp3"

Best Regards,
Croozeus
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
[moved] Theme Studio Error TalJ Themes/Carbide.ui 2 2009-09-06 04:39
open Flash file viswa08 Flash Lite on Nokia Devices 7 2008-09-06 12:29
Unable to create file Ajmal Symbian Media (Graphics & Sounds) 4 2008-06-05 05:39
Problem opening file from a dynamic path didienGanteng General Symbian C++ 12 2007-06-27 12:13
Unable to open a newly created text file? yuva69 General Symbian C++ 1 2002-06-06 15:09

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia