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


Groups > comp.lang.python > #75077

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!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python@mrabarnett.plus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'init': 0.07; '__name__': 0.09; 'assuming': 0.09; 'attributes': 0.09; 'tune': 0.09; 'unittest': 0.09; "'''": 0.16; "'__main__':": 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'missing?': 0.16; 'perfect.': 0.16; 'received:192.168.1.4': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'subject:media': 0.16; 'subject:windows': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'file,': 0.19; 'import': 0.22; 'to:name:python- list@python.org': 0.22; 'header:User-Agent:1': 0.23; 'primary': 0.26; 'header:In-Reply-To:1': 0.27; "i'm": 0.30; 'class': 0.32; 'skip:c 30': 0.32; 'skip:m 30': 0.32; 'run': 0.32; 'another': 0.32; 'skip:d 20': 0.34; 'received:84': 0.35; 'var': 0.36; 'audio': 0.38; 'to:addr:python-list': 0.38; 'files': 0.38; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; "you're": 0.61; 'mate,': 0.84; 'subject:player': 0.84; 'do:': 0.91
X-CM-Score 0.00
X-CNFS-Analysis v=2.1 cv=E5NDpMtl c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=u9EReRu7m0cA:10 a=BYohrxl6zIYA:10 a=ihvODaAuJD4A:10 a=IkcTkHD0fZMA:10 a=EBOSESyhAAAA:8 a=N-AVNhkGor53OqurPJUA:9 a=QEXdDO2ut3YA:10
X-AUTH mrabarnett:2500
Date Wed, 23 Jul 2014 11:57:14 +0100
From MRAB <python@mrabarnett.plus.com>
User-Agent Mozilla/5.0 (Windows NT 6.3; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0
MIME-Version 1.0
To "python-list@python.org" <python-list@python.org>
Subject Re: Automating windows media player on win7
References <A804AEE67207BF42BAF8CEC79839C8D613BF3275@kbnmxexc11.Demant.com> <538F7219.2020705@mrabarnett.plus.com> <A804AEE67207BF42BAF8CEC79839C8D613BF85BA@kbnmxexc11.Demant.com> <A804AEE67207BF42BAF8CEC79839C8D613C3320E@kbnmxexc11.Demant.com>
In-Reply-To <A804AEE67207BF42BAF8CEC79839C8D613C3320E@kbnmxexc11.Demant.com>
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
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.12232.1406113045.18130.python-list@python.org> (permalink)
Lines 91
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1406113045 news.xs4all.nl 2919 [2001:888:2000:d::a6]:42092
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:75077

Show key headers only | View raw


On 2014-07-23 10:20, Deogratius Musiige wrote:
>
> 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:
>
I'm assuming that you're not actually calling the files FileA.py and 
FileB.py.
>
> *FileA.py*
>
You need these imports:

from win32com.client import Dispatch
from time import sleep

> classWMPlayer():
>
> '''
>
>     @
>
>     '''
>
> #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
>
> defplay_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*
>
You need this import:

import unittest

> **
>
> fromwmp.WMPlayer import*
>
> classsTest(unittest.TestCase):
>
> deftest_wmplayer(self):
>
>         self.wmp = WMPlayer()
>
> self.wmp.play_song()
>
You also need to run the test:

if __name__ == '__main__':
     unittest.main()

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


Thread

Re: Automating windows media player on win7 MRAB <python@mrabarnett.plus.com> - 2014-07-23 11:57 +0100

csiph-web