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
Thanks a lot
From: Python-list [mailto:python-list-bounces+demu=senncom....@python.org] On
Behalf Of MRAB
Sent: 4. juni 2014 21:23
Subject: Re: Automating windows media player on win7
On 2014-06-03 09:10, Deogratius Musiige 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")
> raw_input("Press Enter to stop playing")
I've found that adding PlayItem and sleep seems to work:
# -*- coding: utf-8 -*-
from win32com.client import Dispatch
from time import sleep
mp = Dispatch("WMPlayer.OCX")
tune = mp.NewMedia(r"./plays.wav")
raw_input("Press Enter to stop playing")