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


Groups > comp.lang.python > #75073

RE: Automating windows media player on win7

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <DMusiige@sennheisercommunications.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'mrab': 0.05; '-*-': 0.07; 'init': 0.07; 'utf-8': 0.07; 'attributes': 0.09; 'coding:': 0.09; 'juni': 0.09; 'tune': 0.09; 'def': 0.12; 'windows': 0.15; "'''": 0.16; 'guys,': 0.16; 'guys?': 0.16; 'missing?': 0.16; 'perfect.': 0.16; 'skip:[ 50': 0.16; 'subject:media': 0.16; 'subject:windows': 0.16; 'win7': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'looked': 0.18; 'file,': 0.19; 'message-----': 0.19; 'seems': 0.21; 'import': 0.22; 'to:name:python-list@python.org': 0.22; 'driver': 0.24; 'looks': 0.24; "i've": 0.25; '&gt;': 0.26; 'player': 0.26; 'primary': 0.26; 'header:In-Reply-To:1': 0.27; 'skip:( 20': 0.30; 'url:mailman': 0.30; 'work.': 0.31; 'code': 0.31; 'fighting': 0.31; 'option.': 0.31; 'python2.7': 0.31; 'work:': 0.31; 'class': 0.32; 'skip:m 30': 0.32; 'another': 0.32; 'url:python': 0.33; 'device': 0.34; 'skip:_ 10': 0.34; 'skip:d 20': 0.34; 'but': 0.35; 'url:rec-html40': 0.35; 'controls': 0.36; 'var': 0.36; 'url:listinfo': 0.36; 'doing': 0.36; 'charset:us-ascii': 0.36; 'thanks': 0.36; 'url:org': 0.36; 'wrong': 0.37; 'url:microsoft': 0.37; 'email addr:python.org': 0.37; 'received:10': 0.37; 'manager': 0.38; 'audio': 0.38; 'skip:m 40': 0.38; 'url:office': 0.38; 'to:addr:python-list': 0.38; 'files': 0.38; 'skip:- 10': 0.38; 'url:schemas': 0.38; 'track': 0.38; 'url:omml': 0.39; 'url:2004': 0.39; 'subject:': 0.39; 'success.': 0.39; 'url:12': 0.39; 'to:addr:python.org': 0.39; 'url:mail': 0.40; 're:': 0.63; 'day.': 0.63; 'to:2**2': 0.65; 'email name:python-list': 0.65; 'media': 0.66; 'direct': 0.67; 'sound': 0.68; 'mate,': 0.84; 'received:10.242': 0.84; 'subject:player': 0.84; 'do:': 0.91
From Deogratius Musiige <DMusiige@sennheisercommunications.com>
To Deogratius Musiige <DMusiige@sennheisercommunications.com>, MRAB <python@mrabarnett.plus.com>, "python-list@python.org" <python-list@python.org>
Subject RE: Automating windows media player on win7
Thread-Topic Automating windows media player on win7
Thread-Index Ac9/Ao92/LcZpfCnSxeQrPxiZS+XUABFxWqAAFxltGAJMrY4UA==
Date Wed, 23 Jul 2014 09:20:37 +0000
References <A804AEE67207BF42BAF8CEC79839C8D613BF3275@kbnmxexc11.Demant.com> <538F7219.2020705@mrabarnett.plus.com> <A804AEE67207BF42BAF8CEC79839C8D613BF85BA@kbnmxexc11.Demant.com>
In-Reply-To <A804AEE67207BF42BAF8CEC79839C8D613BF85BA@kbnmxexc11.Demant.com>
Accept-Language da-DK, en-US
Content-Language en-US
X-MS-Has-Attach
X-MS-TNEF-Correlator
x-originating-ip [10.100.3.117]
Content-Type multipart/alternative; boundary="_000_A804AEE67207BF42BAF8CEC79839C8D613C3320Ekbnmxexc11Deman_"
MIME-Version 1.0
X-EOPAttributedMessage 0
X-Forefront-Antispam-Report CIP:185.34.132.54; CTRY:EU; IPV:NLI; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(438002)(13464003)(51704005)(377424004)(199002)(189002)(24454002)(76176999)(2656002)(64706001)(87936001)(55846006)(85306003)(83322001)(76482001)(4396001)(77982001)(79102001)(19580405001)(85852003)(33656002)(50986999)(83072002)(15975445006)(19300405004)(53416004)(54356999)(19580395003)(77096002)(19625215002)(21056001)(71186001)(6806004)(92726001)(107886001)(81542001)(44976005)(106466001)(16236675004)(99396002)(95666004)(80022001)(104016003)(46102001)(15202345003)(86362001)(20776003)(84326002)(512954002)(81342001)(74662001)(107046002)(19617315012)(80792004); DIR:OUT; SFP:; SCL:1; SRVR:DB3PR02MB0601; H:mail.demant.com; FPR:; MLV:sfv; PTR:mail1.demant.com; A:1; MX:1; LANG:en;
X-Microsoft-Antispam BCL:0;PCL:0;RULEID:
X-Forefront-PRVS 028166BF91
Received-SPF Pass (: domain of sennheisercommunications.com designates 185.34.132.54 as permitted sender) receiver=; client-ip=185.34.132.54; helo=mail.demant.com;
Authentication-Results spf=pass (sender IP is 185.34.132.54) smtp.mailfrom=DMusiige@sennheisercommunications.com;
X-OriginatorOrg sennheisercommunications.com
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.12228.1406109242.18130.python-list@python.org> (permalink)
Lines 619
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1406109242 news.xs4all.nl 2914 [2001:888:2000:d::a6]:52700
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:75073

Show key headers only | View raw


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

Hi mate,



The fix you provided works perfect. However, if I put it in a class and import, make instance and execute in another file, the audio is not played.

What am I missing? This is what I do:



FileA.py
class WMPlayer():
    '''
    @
    '''
    #static var
    #first instance is a primary , following are secondary.
    #you can have one primary and as many secondary as you like
    def __init__(self):
        '''
        init all attributes
        '''
        #self.mp = Dispatch("WMPlayer.OCX")
        #pass

    def play_song(self):
        mp = Dispatch("WMPlayer.OCX")
        tune = mp.newMedia(r"./SleepAway.mp3")
        mp.currentPlaylist.appendItem(tune)
        mp.controls.play()
        sleep(1)
        mp.controls.playItem(tune)
        raw_input("Press Enter to stop playing")
        #sleep(5)

        mp.controls.stop()



FileB.py

from wmp.WMPlayer import *



class sTest(unittest.TestCase):


    def test_wmplayer(self):
        self.wmp = WMPlayer()

        self.wmp.play_song()







Best regards / Med venlig hilsen



Deogratius Musiige

Sennheiser Communications A/S

Direct                 +45 5618 0320





-----Original Message-----
From: Python-list [mailto:python-list-bounces+demu=senncom.com@python.org] On Behalf Of Deogratius Musiige
Sent: 6. juni 2014 15:39
To: MRAB; python-list@python.org
Subject: RE: Automating windows media player on win7



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



Br

Deo

-----Original Message-----

From: Python-list [mailto:python-list-bounces+demu=senncom.com@python.org] On Behalf Of MRAB

Sent: 4. juni 2014 21:23

To: python-list@python.org<mailto:python-list@python.org>

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")

> mp.currentPlaylist.appendItem(tune)

> mp.controls.play()

> raw_input("Press Enter to stop playing")

> mp.controls.stop()

>

I've found that adding PlayItem and sleep seems to work:



#! python2.7

# -*- coding: utf-8 -*-

from win32com.client import Dispatch

from time import sleep



mp = Dispatch("WMPlayer.OCX")

tune = mp.NewMedia(r"./plays.wav")

mp.CurrentPlaylist.AppendItem(tune)

mp.Controls.Play()

sleep(1)

mp.Controls.PlayItem(tune)

raw_input("Press Enter to stop playing")

mp.Controls.Stop()



--

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



--

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-07-23 09:20 +0000

csiph-web