python使用win32com库播放mp3文件的方法


Posted in Python onMay 30, 2015

本文实例讲述了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 相关文章推荐
Python生成pdf文件的方法
Aug 04 Python
python引用DLL文件的方法
May 11 Python
Python常用内置模块之xml模块(详解)
May 23 Python
Python进阶之尾递归的用法实例
Jan 31 Python
Python实现自定义顺序、排列写入数据到Excel的方法
Apr 23 Python
TensorFlow实现简单卷积神经网络
May 24 Python
mac安装scrapy并创建项目的实例讲解
Jun 13 Python
python3.7 sys模块的具体使用
Jul 22 Python
Python爬虫爬取电影票房数据及图表展示操作示例
Mar 27 Python
Spring http服务远程调用实现过程解析
Jun 11 Python
Python字符串格式化常用手段及注意事项
Jun 17 Python
用pushplus+python监控亚马逊到货动态推送微信
Jan 29 Python
基于wxpython开发的简单gui计算器实例
May 30 #Python
python图像处理之镜像实现方法
May 30 #Python
python图像处理之反色实现方法
May 30 #Python
python中字典(Dictionary)用法实例详解
May 30 #Python
python集合用法实例分析
May 30 #Python
基于wxpython实现的windows GUI程序实例
May 30 #Python
python简单实现旋转图片的方法
May 30 #Python
You might like
深入php之规范编程命名小结
2013/05/15 PHP
Yii使用smsto短信接口的函数demo示例
2016/07/13 PHP
老生常谈PHP 文件写入和读取(必看篇)
2017/05/22 PHP
PHP构造二叉树算法示例
2017/06/21 PHP
php基于自定义函数记录log日志方法
2017/07/21 PHP
PHP+ajax实现获取新闻数据简单示例
2018/05/08 PHP
解决PHP Opcache 缓存刷新、代码重载出现无法更新代码的问题
2020/08/24 PHP
JS中的Replace方法使用经验分享
2015/05/20 Javascript
javascript中return,return true,return false三者的用法及区别
2015/11/17 Javascript
javascript合并表格单元格实例代码
2016/01/03 Javascript
Javascript函数中的arguments.callee用法实例分析
2016/09/16 Javascript
炫酷的js手风琴效果
2016/10/13 Javascript
原生js轮播特效
2017/05/18 Javascript
浅谈React中组件间抽象
2018/01/27 Javascript
Angular 数据请求的实现方法
2018/05/07 Javascript
超简单的微信小程序轮播图
2019/11/22 Javascript
vue中使用elementUI组件手动上传图片功能
2019/12/13 Javascript
[03:56]显微镜下的DOTA2第十一期——鬼畜的死亡先知播音员
2014/06/23 DOTA
[06:53]2018DOTA2国际邀请赛寻真——勇于创新的Vici Gaming
2018/08/14 DOTA
[43:41]VP vs RNG 2019国际邀请赛淘汰赛 败者组 BO3 第二场 8.21.mp4
2020/07/19 DOTA
解析Python中的二进制位运算符
2015/05/13 Python
解析Python编程中的包结构
2015/10/25 Python
Python三级目录展示的实现方法
2016/09/28 Python
用Python将IP地址在整型和字符串之间轻松转换
2017/03/22 Python
Python三级菜单的实例
2017/09/13 Python
Python数据结构与算法之图的广度优先与深度优先搜索算法示例
2017/12/14 Python
增大python字体的方法步骤
2020/07/05 Python
Python实现淘宝秒杀功能的示例代码
2021/01/19 Python
详解python的变量缓存机制
2021/01/24 Python
配置管理计划的主要内容有哪些
2014/06/20 面试题
中软国际Java程序员机试题
2012/08/19 面试题
打架检讨书100字
2014/01/08 职场文书
四风专项整治工作情况汇报
2014/10/28 职场文书
2014年学校总务处工作总结
2014/12/08 职场文书
学校2016年九九重阳节活动总结
2016/04/01 职场文书
一文解答什么是MySQL的回表
2022/08/05 MySQL