Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #72501

RE: Automating windows media player on win7

From Deogratius Musiige <DMusiige@sennheisercommunications.com>
Subject RE: Automating windows media player on win7
Date 2014-06-03 09:42 +0000
References <A804AEE67207BF42BAF8CEC79839C8D613BF3275@kbnmxexc11.Demant.com> <CAPTjJmrN0kUZ2A9Y9h0j_sL=nzmDa7aiVPAnZnbeLjRB=OOVCA@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.10613.1401791313.18130.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

Hi Chris,

I want to have wmplayer as part of my automitized test for a headset via the USB HID.

I want to be able to execute some of the following operations in my python script:

1.       Play

2.       Get playing track

3.       Next

4.       Get active device

5.       ...

I am not sure if you are able to do this with your project



Best regards / Med venlig hilsen

Deo





-----Original Message-----
From: Python-list [mailto:python-list-bounces+demu=senncom.com@python.org] On Behalf Of Chris Angelico
Sent: 3. juni 2014 10:58
Cc: python-list@python.org
Subject: Re: Automating windows media player on win7



On Tue, Jun 3, 2014 at 6:10 PM, Deogratius Musiige <DMusiige@sennheisercommunications.com<mailto:DMusiige@sennheisercommunications.com>> wrote:

> Hi guys,

>

>

>

> I have been fighting with automating wmplayer but with no success.

>

> It looks to me that using the .OCX would be the best option. I found

> the code below on the net but I cannot get it to work.

>

> I can see from device manager that a driver is started by I get no

> audio out.

>

> What am I doing wrong guys?

>

>

>

> # this program will play MP3, WMA, MID, WAV files via the

> WindowsMediaPlayer

>

> from win32com.client import Dispatch

>

> mp = Dispatch("WMPlayer.OCX")

>

> tune = mp.newMedia("./plays.wav")

>

> mp.currentPlaylist.appendItem(tune)

>

> mp.controls.play()

>

> raw_input("Press Enter to stop playing")

>

> mp.controls.stop()

>

>

>

> Br

>

> Deo



First suggestion: post plain text to this list, not HTML. You don't need it to look like the above. :)



Secondly: Is there a particular reason that you need to be automating Windows Media Player specifically? I have a similar project which works by sending keystrokes, which means it works with anything that reacts to keys; mainly, I use it with VLC. It can invoke a movie or audio file, can terminate the process, and can send a variety of commands via keys. It's designed to be used on a (trusted) LAN.



Code is here:

https://github.com/Rosuav/Yosemite



Once something's invoked by the Yosemite project, it simply runs as normal inside VLC. Easy to debug audio problems, because they're managed the exact same way. Granted, this does assume that it's given full control of the screen (it's designed to manage full-screen video playback; in fact, my siblings are right now watching Toy Story 3 in the other room, using an old laptop driving a TV via S-Video, all managed via the above project), so it may not be ideal for background music on a computer you use for other things; but feel free to borrow ideas and/or code from there. (And for what it's worth, I use this as one of my sources of BGM when I'm coding - just let it invoke the file, then manually flip focus back to what I'm doing.)



ChrisA

--

https://mail.python.org/mailman/listinfo/python-list

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

RE: Automating windows media player on win7 Deogratius Musiige <DMusiige@sennheisercommunications.com> - 2014-06-03 09:42 +0000

csiph-web