[Python] python通过win32com库播放mp3文件 →→→→→进入此内容的聊天室

来自 , 2019-05-29, 写在 Python, 查看 134 次.
URL http://www.code666.cn/view/5ad742cd
  1. # Python supports COM, if you have the Win32 extensions
  2. # check your Python folder eg.  D:\Python23\Lib\site-packages\win32com
  3. # also http://starship.python.net/crew/mhammond/win32/Downloads.html
  4. # this program will play MP3, WMA, MID, WAV files via the WindowsMediaPlayer
  5. from win32com.client import Dispatch
  6. mp = Dispatch("WMPlayer.OCX")
  7. # use an mp3 file you have ...
  8. #tune = mp.newMedia("C:/Program Files/Common Files/HP/Memories Disc/2.0/audio/Swing.mp3")
  9. # or copy one to the working folder ...
  10. #tune = mp.newMedia("Bier1.mp3")
  11. # you can also play wma files, this cool sound came with XP ...
  12. tune = mp.newMedia("C:/WINDOWS/system32/oobe/images/title.wma")
  13. mp.currentPlaylist.appendItem(tune)
  14. mp.controls.play()
  15. # to stop playing use
  16. raw_input("Press Enter to stop playing")
  17. mp.controls.stop()
  18. #//python/5733

回复 "python通过win32com库播放mp3文件"

这儿你可以回复上面这条便签

captcha