美文网首页
python通过win32com库播放mp3文件的代码

python通过win32com库播放mp3文件的代码

作者: we1212 | 来源:发表于2021-11-14 21:37 被阅读0次

下边内容段是关于python通过win32com库播放mp3文件的内容,应该能对大家有用处。

# Python supports COM, if you have the Win32 extensions

# check your Python folder eg.  D:Python23Libsite-packageswin32com

# 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通过win32com库播放mp3文件的代码

      本文链接:https://www.haomeiwen.com/subject/vgoxtrtx.html