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


Groups > comp.lang.python > #72493 > unrolled thread

Re: Automating windows media player on win7

Started byChris Angelico <rosuav@gmail.com>
First post2014-06-03 18:57 +1000
Last post2014-06-03 18:57 +1000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Automating windows media player on win7 Chris Angelico <rosuav@gmail.com> - 2014-06-03 18:57 +1000

#72493 — Re: Automating windows media player on win7

FromChris Angelico <rosuav@gmail.com>
Date2014-06-03 18:57 +1000
SubjectRe: Automating windows media player on win7
Message-ID<mailman.10607.1401785863.18130.python-list@python.org>
On Tue, Jun 3, 2014 at 6:10 PM, Deogratius Musiige
<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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web