By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,548 Members | 1,495 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,548 IT Pros & Developers. It's quick & easy.

Controlling Windows Media Player from Python

P: n/a
Is there a way to interact with Windows Media Player from Python? I would
like to be able to do things like tell WMP to play a given sound file or to
ask WMP for metadata about a sound file.
--
Jeffrey Barish

Jul 3 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a

Jeffrey Barish wrote:
Is there a way to interact with Windows Media Player from Python? I would
like to be able to do things like tell WMP to play a given sound file or to
ask WMP for metadata about a sound file.
--
Jeffrey Barish


The fact of the matter is that python doesn't need to ask WMP for the
metadata. Python can get the metadata from the file itself and then
tell the computer to play the file.

If you're looking to do something more complicated, try PyMedia or even
download wxPython and take a look at the examples. There's an embedded
WMP example.

By the way, someone has most likely made a module specifically for
reading the metadata from many types of music files, but I don't have
time to look. Maybe someone else can point you in the right direction.
For telling WMP to play the file you want one of the os.exec variants.

Jul 3 '06 #2

P: n/a
Jeffrey Barish <je*********@earthlink.netwrote:
Is there a way to interact with Windows Media Player from Python? I would
like to be able to do things like tell WMP to play a given sound file or to
ask WMP for metadata about a sound file.
Take a look at pywinauto, I attended the today talk at EP2006 and seemed
really cool. http://pywinauto.pbwiki.com

--
Lawrence - http://www.oluyede.org/blog
"Nothing is more dangerous than an idea
if it's the only one you have" - E. A. Chartier
Jul 4 '06 #3

P: n/a
"Jeffrey Barish" <je*********@earthlink.netwrote in message news:ma***************************************@pyt hon.org...
Is there a way to interact with Windows Media Player from Python? I would
like to be able to do things like tell WMP to play a given sound file or to
ask WMP for metadata about a sound file.
--
Jeffrey Barish
WMP can be automated using COM:

import win32com.client

w=win32com.client.gencache.EnsureDispatch('WMPlaye r.OCX',0)
pl=w.playlistCollection.getByName('All Music')[0]
s=pl[0]
print s.name, s.duration
w.currentMedia=s

Roger
Jul 4 '06 #4

P: n/a
>
Take a look at pywinauto, I attended the today talk at EP2006 and seemed
really cool. http://pywinauto.pbwiki.com

Cool, that looks really interesting.

....theres a problem I could solve with that....
Jul 4 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.