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


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

Re: Automating windows media player on win7

Started byMRAB <python@mrabarnett.plus.com>
First post2014-06-08 00:02 +0100
Last post2014-06-08 00:02 +0100
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 MRAB <python@mrabarnett.plus.com> - 2014-06-08 00:02 +0100

#72934 — Re: Automating windows media player on win7

FromMRAB <python@mrabarnett.plus.com>
Date2014-06-08 00:02 +0100
SubjectRe: Automating windows media player on win7
Message-ID<mailman.10865.1402182142.18130.python-list@python.org>
On 2014-06-06 14:39, Deogratius Musiige wrote:
> Thanks a lot mate.
>
> You just made my day.
> I have looked around the net but cannot find the controls available.
>
> I would like to be able to:
> - get current playing track
> - get wmplayer state (playing/paused/stopped)
> - get the selected sound device
>
[snip]
Here's a bit more. Note how it seems to need short sleeps after certain
actions (I don't know why!):

#! python2.7
# -*- coding: utf-8 -*-
import pywintypes
from win32com.client import Dispatch
from time import sleep

tunes = ["./plays.wav", "./plays.wav", "./plays.wav"] # Whatever

mp = Dispatch("WMPlayer.OCX")

for name in tunes:
     tune = mp.NewMedia(name)
     mp.CurrentPlaylist.AppendItem(tune)

mp.Controls.Play()
sleep(0.25)

for i in range(len(tunes)):
     print "Current tune is", mp.Controls.CurrentItem.Name

     print 'Playing current tune'
     mp.Controls.PlayItem(mp.Controls.CurrentItem)
     print 'mp.Status says', mp.Status

     sleep(5)

     print 'Pausing'
     mp.Controls.Pause()
     print 'mp.Status says', mp.Status

     sleep(2)

     print 'Resuming'
     mp.Controls.Play()
     print 'mp.Status says', mp.Status
     sleep(5)

     mp.Controls.Next()
     sleep(0.25)

mp.Controls.Stop()

[toc] | [standalone]


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


csiph-web