473,786 Members | 2,765 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Controlling Windows Media Player from Python

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
4 8048

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
Jeffrey Barish <je*********@ea rthlink.netwrot e:
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
"Jeffrey Barish" <je*********@ea rthlink.netwrot e in message news:ma******** *************** *************** *@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.clie nt.gencache.Ens ureDispatch('WM Player.OCX',0)
pl=w.playlistCo llection.getByN ame('All Music')[0]
s=pl[0]
print s.name, s.duration
w.currentMedia= s

Roger
Jul 4 '06 #4
>
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1911
by: Bart Simpson | last post by:
Hi, I would like to create/delete ftp accounts of windows IIS, and to control MS Media Service under windows 2003 by Python program. A few days ago, I found there is iisftp.vbs vb-script that can creat/delete IIS ftp account. But I've suspected the iisftp cannot configure detailed configueration. (ex. It can't configure anonymous-login and home directory
0
2077
by: Mickel Grönroos | last post by:
Hi! Anybody tried using Windows Media Player 9 via win32com? (And more precisely, combining that with a Tkinter application.) I found a few earlier threads on Windows Media Player and Python, but it seems nobody has really got it to work, e.g. the below does not work: wmp = win32com.client.Dispatch("MediaPlayer.MediaPlayer.1") wmp.FileName = "C:/Path/To/Some/Media/File.wav"
1
8917
by: Anise | last post by:
I have a question concerning embedding a windows media player into a web application in .net.. I download Windows Media Player 10 and its SDK On the .ascx page I placed a windows media player object from the toolbox and all the sites i read say when "Adding the Windows Media Player control from the Toolbox also adds references to two libraries created by Visual
1
7898
by: Stephen Adam | last post by:
Hi there, Have spent a while trying to find out how to connect to Windows Media Player through COM. Unfortunately there doesnt seem to be much stuff about it on the web. What I need to do is create a simple console application which will be able to find out what the values of a currently playing tack. I've downloaded the Windows Media player SDK which come with some IDL and
4
7837
by: BobAchgill | last post by:
What is the best way to show a video file directly in a Form? Can I use functions of Windows Player in a Windows Form? Functions like: play video or show visualization for music, etc.
3
5193
by: UJ | last post by:
I have a .avi file that uses the Divx codec. If I load it with windows media player program it works fine. If I load it using my control in a program, it doesn't display. Over standard media files work fine so it's this particular file. Do I have to do anything when the file uses a non-included codec? How can I tell what Codec it's using? TIA - Jeff.
1
5551
by: sri2097 | last post by:
Basically, I want to check if a URL is playable or not (without actually playing it). i.e. given a URL I want to write an automation script to figure it out for me if it's playable or not. If you give a bad/invalid URL for windows media player to play a pop-up window shows us that it cannot be played. So I would want to catch that event.
3
13494
by: Herb | last post by:
I've found how to use javascript to embed a Windows Media Player in a web page. How do I go about controlling the player in response to user input? There should be calls to start, stop and also to play at a certain position. For instance, I'd like to have a video playing. Along with that, I'd present a list of 10 chapters within the video. When a user clicks a link, the player should play the appropriate chapter or section. Thanks.
0
2668
by: artsohc | last post by:
Hey Everyone, this is my first time posting so go easy on me. I am trying to hook up music-on-hold at the office I work at. I got all the music loaded and I got Windows Media Player working while the phones are on hold, but now I am trying to write a script that will allow Windows Media Player to run as a service so I can make it auto-start with out needing a user logged in on the computer. Also it would allow the music-on-hold to work if we...
0
9496
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10164
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9961
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8989
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3669
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.