win32com: passing object to threads

Markus von Ehr vonehr at ira.uka.de
Thu Feb 1 08:47:57 EST 2001


Hi,

I play a mp3 File with MediaPlayer using COM like this:
(Globals. are my global variables)

  Globals.ie =
win32com.client.dynamic.Dispatch("InternetExplorer.Application")
  Globals.ie.Navigate(r'about:blank')
  Globals.doc = Globals.ie.Document
  Globals.doc.body.insertAdjacentHTML("afterBegin",
  """
  <OBJECT ID="MediaPlayer1"
  CLASSID="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95">
  </OBJECT>
  """)
    
  Globals.mp = Globals.doc.body.children("MediaPlayer1").object

  Globals.mp.FileName = "MySoundFile.mp3"

In another thread I want to set the New SoundFile:

  Globals.mp.FileName = "null.wav"

and I have the error:

  Pythoncomerror, (-2147221008, 'CoInitialize hasn't been called', None,
None)

I know that I have to use the: pythoncom.CoInitialize() and 
pythoncom.CoUninitialize() in a way, but don't know why. 
Can anybody help me?

Thanks a lot for any answer,

Markus



More information about the Python-list mailing list