Automating windows media player

后端 未结 3 753
-上瘾入骨i
-上瘾入骨i 2021-01-29 06:10

Any ideas about controling windows media player in Python? I found the following code on the net which runs fine but no audio is played. am using win7 64 bit machine

<         


        
3条回答
  •  孤独总比滥情好
    2021-01-29 06:27

    It helps me to use Windows Media COM. When I tried it, I need to make 2 small modification to make it working in Python Flask.

    1. CoInitialize to make it single thread i.e. pythoncom.CoInitialize() and pythoncom.CoUninitialize()
    2. PumpWaitMessage to keep MediaPlayer working i.e while mp.PlayState != 1: pythoncom.PumpWaitingMessages()

提交回复
热议问题