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编程-将Python程序转化为可执行程序[整理]
Apr 09 Python
Python 用户登录验证的小例子
Mar 06 Python
python写xml文件的操作实例
Oct 05 Python
Python中的__new__与__init__魔术方法理解笔记
Nov 08 Python
深入理解Python中的*重复运算符
Oct 28 Python
Python字符串拼接六种方法介绍
Dec 18 Python
python生成以及打开json、csv和txt文件的实例
Nov 16 Python
解决python web项目意外关闭,但占用端口的问题
Dec 17 Python
python自动脚本的pyautogui入门学习
Apr 01 Python
用python实现一个简单的验证码
Dec 09 Python
python中的unittest框架实例详解
Feb 05 Python
python 基于pygame实现俄罗斯方块
Mar 02 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程序--记数器
2006/10/09 PHP
给初学者的30条PHP最佳实践(荒野无灯)
2011/08/02 PHP
解析mysql left( right ) join使用on与where筛选的差异
2013/06/18 PHP
PHP读取文件内容后清空文件示例代码
2014/03/18 PHP
PHP实现微信公众平台音乐点播
2014/03/20 PHP
PHP+Mysql基于事务处理实现转账功能的方法
2015/07/08 PHP
Yii2基于Ajax自动获取表单数据的方法
2016/08/10 PHP
PHP异常处理定义与使用方法分析
2017/07/25 PHP
php中字符串和整数比较的操作方法
2019/06/06 PHP
php中yii框架实例用法
2020/12/22 PHP
Mootools 1.2教程 输入过滤第二部分(字符串)
2009/09/15 Javascript
基于jquery实现鼠标左右拖动滑块滑动附源码下载
2015/12/23 Javascript
jQuery中DOM节点删除之empty与remove
2017/01/20 Javascript
JavaScript获取tr td 的三种方式全面总结(推荐)
2017/08/15 Javascript
深入理解JavaScript和TypeScript中的class
2018/04/22 Javascript
vue 双向数据绑定的实现学习之监听器的实现方法
2018/11/30 Javascript
使用imba.io框架得到比 vue 快50倍的性能基准
2019/06/17 Javascript
[03:48]DOTA2完美大师赛主赛事第二日精彩集锦
2017/11/24 DOTA
[00:23]魔方之谜解锁款式
2018/12/20 DOTA
[01:11:28]DOTA2-DPC中国联赛定级赛 RNG vs Phoenix BO3第一场 1月8日
2021/03/11 DOTA
vscode 远程调试python的方法
2017/12/01 Python
利用Django-environ如何区分不同环境
2018/08/26 Python
python GUI库图形界面开发之PyQt5表单布局控件QFormLayout详细使用方法与实例
2020/03/06 Python
Jupyter Notebook的连接密码 token查询方式
2020/04/21 Python
Python pandas如何向excel添加数据
2020/05/22 Python
基于IE10/HTML5 开发
2013/04/22 HTML / CSS
戴尔英国翻新电脑和电子产品:Dell UK Refurbished Computers
2019/07/30 全球购物
业务员岗位职责
2013/11/16 职场文书
党的群众路线教育实践活动批评与自我批评
2014/02/16 职场文书
社区党员志愿服务活动方案
2014/08/18 职场文书
一份没有按时交货失信于客户的检讨书
2014/09/19 职场文书
2015商场元旦促销活动策划方案
2014/12/09 职场文书
2015年学校政教工作总结
2015/07/20 职场文书
Python超简单容易上手的画图工具库推荐
2021/05/10 Python
Arthas排查Kubernetes中应用频繁挂掉重启异常
2022/02/28 MySQL
漫画「请问您今天要来点兔子吗?」最新杂志彩页公开
2022/03/24 日漫