python使用win32com庫播放mp3文件的方法
更新時間:2015年05月30日 12:26:09 作者:皮蛋
這篇文章主要介紹了python使用win32com庫播放mp3文件的方法,涉及Python使用win32com庫操作音頻文件的相關(guān)技巧,需要的朋友可以參考下
本文實例講述了python使用win32com庫播放mp3文件的方法。分享給大家供大家參考。具體實現(xiàn)方法如下:
# 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程序設(shè)計有所幫助。
相關(guān)文章
用實例詳解Python中的Django框架中prefetch_related()函數(shù)對數(shù)據(jù)庫查詢的優(yōu)化
這篇文章主要介紹了用實例詳解Python中的Django框架中prefetch_related()函數(shù)對數(shù)據(jù)庫查詢的優(yōu)化,可減少對數(shù)據(jù)庫的查詢次數(shù)從而優(yōu)化性能,需要的朋友可以參考下2015-04-04淺談keras使用預(yù)訓(xùn)練模型vgg16分類,損失和準(zhǔn)確度不變
這篇文章主要介紹了淺談keras使用預(yù)訓(xùn)練模型vgg16分類,損失和準(zhǔn)確度不變,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編小編過來看看吧2020-07-07python GUI庫圖形界面開發(fā)之PyQt5動態(tài)(可拖動控件大小)布局控件QSplitter詳細(xì)使用方法與實例
這篇文章主要介紹了python GUI庫圖形界面開發(fā)之PyQt5動態(tài)(可拖動控件大小)布局控件QSplitter詳細(xì)使用方法與實例,需要的朋友可以參考下2020-03-03