手机
当前位置:查字典教程网 >脚本专栏 >python >python使用win32com库播放mp3文件的方法
python使用win32com库播放mp3文件的方法
摘要:本文实例讲述了python使用win32com库播放mp3文件的方法。分享给大家供大家参考。具体实现方法如下:#Pythonsupports...

本文实例讲述了python使用win32com库播放mp3文件的方法。分享给大家供大家参考。具体实现方法如下:

# Python supports COM, if you have the Win32 extensions # check your Python folder eg. D:Python23Libsite-packageswin32com # 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使用win32com库播放mp3文件的方法】相关文章:

python二叉树遍历的实现方法

Python中使用动态变量名的方法

python使用cookielib库示例分享

python 不关闭控制台的实现方法

netbeans7安装python插件的方法图解

Python实现扫描指定目录下的子目录及文件的方法

Python strip lstrip rstrip使用方法

Python的函数嵌套的使用方法

python处理文本文件实现生成指定格式文件的方法

python生成器的使用方法

精品推荐
分类导航