python使用win32com库播放mp3文件的方法
更新时间:2015年05月30日 12:26:09 作者:皮蛋
这篇文章主要介绍了python使用win32com库播放mp3文件的方法,涉及Python使用win32com库操作音频文件的相关技巧,需要的朋友可以参考下
本文实例讲述了python使用win32com库播放mp3文件的方法。分享给大家供大家参考。具体实现方法如下:
# Python supports COM, if you have the Win32 extensions # check your Python folder eg. D:\Python23\Lib\site-packages\win32com # also http://starship.python.net/crew/mhammond/win32/Downloads.html # this program will play MP3, WMA, MID, WAV files via the WindowsMediaPlayer from win32com.client import Dispatch mp = Dispatch("WMPlayer.OCX") # use an mp3 file you have ... #tune = mp.newMedia("C:/Program Files/Common Files/HP/Memories Disc/2.0/audio/Swing.mp3") # or copy one to the working folder ... #tune = mp.newMedia("Bier1.mp3") # you can also play wma files, this cool sound came with XP ... tune = mp.newMedia("C:/WINDOWS/system32/oobe/images/title.wma") mp.currentPlaylist.appendItem(tune) mp.controls.play() # to stop playing use raw_input("Press Enter to stop playing") mp.controls.stop()
希望本文所述对大家的Python程序设计有所帮助。
相关文章
Python、 Pycharm、Django安装详细教程(图文)
这篇文章主要介绍了Python、 Pycharm、Django安装详细教程,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧2019-04-04已安装tensorflow-gpu,但keras无法使用GPU加速的解决
今天小编就为大家分享一篇已安装tensorflow-gpu,但keras无法使用GPU加速的解决,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧2020-02-02
最新评论