Is it possible to open a mp3 file in python (possible using POPEN) and i dont mean to run it in the program i mean as a separate window in media player or whatever just for it to open it when i call the function and if so how. thanks a lot.
+5
A:
Opening a file with its associated application (Windows only):
import os
os.startfile('my_mp3.mp3')
A link to the documentation can be found here.
ChristopheD
2010-07-07 20:42:13
Cool. Wasn't aware of that.
James Roth
2010-07-07 20:43:39
it threw an error it said : Traceback (most recent call last): File "C:\Users\matt\Desktop\1.py", line 3, in <module> os.startfile('C:\Users\matt\Desktop\test.mp3')WindowsError: [Error 2] The system cannot find the file specified: 'C:\\Users\\matt\\Desktop\test.mp3'
Matthew Carter
2010-07-07 20:48:55
here is the script import os os.startfile('C:\Users\matt\Desktop\test.mp3')
Matthew Carter
2010-07-07 20:50:07
@Matthew Carter: you probably need to double your backslashes (`import os ; os.startfile('C:\\Users\\matt\\Desktop\\test.mp3')` or use forward slash...
ChristopheD
2010-07-07 20:53:24
wait never mind it worked i thought i needed to put the full path i guess not.
Matthew Carter
2010-07-07 20:53:46
In the documentation I linked to it states `os.startfile` by default expects paths starting from the current working directory, although you *can* use absolute paths (the previous comment about the need to double your backslashes still holds true though).
ChristopheD
2010-07-07 20:57:32
+1
A:
Here is the Python docs for Python in Music: http://wiki.python.org/moin/PythonInMusic
Listed there are libraries for opening and playing mp3, amongst other formats.
kobrien
2010-07-07 20:47:31