[python-win32] COM works from IDLE but not when file executed from Windows Explorer
Tim Roberts
timr at probo.com
Wed Mar 14 17:41:17 CET 2007
new2com wrote:
> Installed: Python25, pywin32-210.win32-py2.5.exe
> Being new to COM, I have a simple question. When I execute the following
> code from within IDLE, I hear the mp3 file played out but when I run the
> file from Windows Explorer I get no sound (and no errors) ?
>
By "run the file from Windows Explorer", do you mean you double-click on
the icon?
> I'm sure the answer is very simple !
>
> ( http://www.nabble.com/file/6954/playFile.py playFile.py ):
>
> from win32com.client import Dispatch
>
> if __name__ == "__main__":
> mp = Dispatch("WMPlayer.OCX")
> tune = mp.newMedia('my_file.mp3')
> mp.currentPlaylist.appendItem(tune)
> mp.controls.play()
> raw_input("Press Enter to stop playing")
> mp.controls.stop()
My guess is that you aren't in the same directory, so that "my_file.mp3"
is not found. Explorer might be setting the starting directory to the
directory that contains python.exe (since that's what it is really
executing) instead of the directory with your script.
You might try providing the full path to the file, instead of just a
relative path.
--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-win32
mailing list