Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #75080
| From | Deogratius Musiige <DMusiige@sennheisercommunications.com> |
|---|---|
| Subject | RE: Automating windows media player on win7 |
| Date | 2014-07-23 11:55 +0000 |
| References | <A804AEE67207BF42BAF8CEC79839C8D613BF3275@kbnmxexc11.Demant.com> <538F7219.2020705@mrabarnett.plus.com> <A804AEE67207BF42BAF8CEC79839C8D613BF85BA@kbnmxexc11.Demant.com> <A804AEE67207BF42BAF8CEC79839C8D613C3320E@kbnmxexc11.Demant.com> <53CF950A.8040905@mrabarnett.plus.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.12235.1406116507.18130.python-list@python.org> (permalink) |
Hi,
I have the mentioned imports. And for the matter of fact I can play the audio.
The problem is when I make a class with the wmplayer automating code and make an instance of this class in my testing code.
When I run this instance, I do not get any audio out?
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 MRAB
Sent: 23. juli 2014 12:57
To: python-list@python.org
Subject: Re: Automating windows media player on win7
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()
--
https://mail.python.org/mailman/listinfo/python-list
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
RE: Automating windows media player on win7 Deogratius Musiige <DMusiige@sennheisercommunications.com> - 2014-07-23 11:55 +0000
csiph-web