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

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

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

皮蛋   2021-03-21 我要评论
想了解python使用win32com库播放mp3文件的方法的相关内容吗,皮蛋在本文为您仔细讲解python使用win32com库播放mp3文件的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:python,win32com库,播放,mp3文件,下面大家一起来学习吧。

本文实例讲述了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程序设计有所帮助。

猜您喜欢

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们