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


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

Re: Automating windows media player on win7

Started byMRAB <python@mrabarnett.plus.com>
First post2014-07-23 11:57 +0100
Last post2014-07-23 11:57 +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-07-23 11:57 +0100

#75077 — Re: Automating windows media player on win7

FromMRAB <python@mrabarnett.plus.com>
Date2014-07-23 11:57 +0100
SubjectRe: Automating windows media player on win7
Message-ID<mailman.12232.1406113045.18130.python-list@python.org>
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()

[toc] | [standalone]


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


csiph-web