关于在Python中控制Windows媒体播放器的任何想法?我发现在网上运行良好,但没有音频播放下面的代码。我正在使用win7 64位机器自动化Windows媒体播放器
# this program will play MP3, WMA, MID, WAV files via the WindowsMediaPlayer
from win32com.client import Dispatch
mp = Dispatch("WMPlayer.OCX")
#tune = mp.newMedia("./SleepAway.mp3")
tune = mp.newMedia("./plays.wav")
mp.currentPlaylist.appendItem(tune)
mp.controls.play()
raw_input("Press Enter to stop playing")
mp.controls.stop()
WMP的音量设置? –
这可能与[本周遇到的问题]有关(https://stackoverflow.com/questions/25157138)。关键是要确保您在控制线程中抽取Windows消息。 raw_input不这样做。 –
我对于一个有相同的问题,使用Windows 7和python以编程方式播放声音...如果你想要看到我的问题,但它永远不会解决。看起来你可以很好地使用os.startfile,也许可以看看。这里是我的问题在http://stackoverflow.com/questions/20696948/how-to-do-text-to-speech-with-python-on-a-toshiba-laptop-and-windows-7 –