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