【脚本语言系列】关于Python音频处理WMPlayerOCX,你需要知道的事情
来源:互联网 发布:飞狐软件免费吗 编辑:程序博客网 时间:2024/05/29 09:08
如何使用WMPlayerOCX
# -*- coding:utf-8 -*-#import Tkinterimport tkFileDialogfrom win32com.client import Dispatchclass Window: def __init__(self): self.root = root = Tkinter.Tk() buttonAdd = Tkinter.Button(root, text = 'Add', command = self.add) buttonAdd.place(x = 150, y = 15) buttonPlay = Tkinter.Button(root, text = 'Play', command = self.play) buttonPlay.place(x = 200, y = 15) buttonPause = Tkinter.Button(root, text = 'Pause', command = self.pause) buttonPause.place(x = 250, y = 15) buttonStop = Tkinter.Button(root, text = 'Stop', command = self.stop) buttonStop.place(x = 300, y = 15) buttonNext = Tkinter.Button(root, text = 'Next', command = self.next) buttonNext.place(x = 350, y = 15) frame = Tkinter.Frame(root, bd = 2) self.playList = Tkinter.Text(frame) scrollbar = Tkinter.Scrollbar(frame) scrollbar.config(command = self.playList.yview) self.playList.pack(side = Tkinter.LEFT) scrollbar.pack(side=Tkinter.RIGHT, fill=Tkinter.Y) frame.place(y = 50) self.wmp = Dispatch('WMPlayer.OCX') def MainLoop(self): self.root.minsize(510,380) self.root.maxsize(510,380) self.root.mainloop() def add(self): file = tkFileDialog.askopenfilename(title = 'Python Music Player', filetypes = [('MP3', '*.mp3'),('WMA', '*.wma'),('WAV','.wav')]) if file: media = self.wmp.newMedia(file) self.wmp.currentPlaylist.appendItem(media) self.playList.insert(Tkinter.END, file+'\n') def play(self): self.wmp.controls.play() def pause(self): self.wmp.controls.pause() def next(self): self.wmp.controls.next() def stop(self): self.wmp.controls.stop()window = Window()window.MainLoop()
1. 增加音频文件
2. 点击播放音频文件
3. 暂停/停止播放音频文件
4. 播放下个音频文件
什么是WMPlayerOCX
由于PythonWin提供了对COM组件的支持,因此可以在Python中直接使用WMPlayer.OCX组件来播放音频文件。
阅读全文
0 0
- 【脚本语言系列】关于Python音频处理WMPlayerOCX,你需要知道的事情
- 【脚本语言系列】关于Python音频处理DirectSound, 你需要知道的事
- 【脚本语言系列】关于Python操作数据二进制数据,你需要知道的事情
- 【脚本语言系列】关于Python系统管理,你需要知道的事
- 【脚本语言系列】关于Python容器,你需要知道的事
- 【脚本语言系列】关于Python图像处理PIL,你需要知道的事
- 【脚本语言系列】关于Python数据库处理SQLite,你需要知道的事
- 【脚本语言系列】关于Python数据库处理MySQL, 你需要知道的事
- 【脚本语言系列】关于Python基础知识处理字符串,你需要知道的事
- 【脚本语言系列】关于Python异常处理,你需要知道的事
- 【脚本语言系列】关于Python数据库处理SQLite数据库,你需要知道的事
- 【脚本语言系列】关于Python数据库处理SQLAlchemy,你需要知道的事
- 【脚本语言系列】关于Python结构化文本文件处理YAML,你需要知道的事
- 【脚本语言系列】关于Python结构化文本文件处理csv,你需要知道的事
- 【脚本语言系列】关于Python结构化文本文件处理xml,你需要知道的事
- 【脚本语言系列】关于Python结构化文本文件处理HTML,你需要知道的事
- 【脚本语言系列】关于Python结构化文本文件处理JSON,你需要知道的事
- 【脚本语言系列】关于Python结构化文本文件处理配置文件.ini,你需要知道的事
- 25. Reverse Nodes in k-Group
- 小型电商服务器平台搭建(一)
- 栈和队列判断回文数
- oracle 锁
- 多个APP共存Django配置
- 【脚本语言系列】关于Python音频处理WMPlayerOCX,你需要知道的事情
- win10下使用nodejs安装
- 位置、变换的表示
- HDOJ 2029 Palindromes _easy version
- java 构造方法和一般方法的区别
- 使用VC的API函数操作临界区
- oracle 安装和配置
- 基于pytesseract的验证码识别
- 赫夫曼编码