Controlling Windows Media Player from Python

Roger Upole rupole at hotmail.com
Tue Jul 4 02:35:04 EDT 2006


"Jeffrey Barish" <jeff_barish at earthlink.net> wrote in message news:mailman.7729.1151941150.27775.python-list at python.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('WMPlayer.OCX',0)
pl=w.playlistCollection.getByName('All Music')[0]
s=pl[0]
print s.name, s.duration
w.currentMedia=s

       Roger





More information about the Python-list mailing list