安装开发依赖
上述软件只需要两个python包
- pip install python-vlc -i https://pypi.douban.com/simple/
- pip install PySimpleGUI -i https://pypi.douban.com/simple/
大家看到我安装的时候指定了python的pip源,因为不指定报错如下:
然后将下述代码拷贝到本地执行
import PySimpleGUI as sg
import vlc
controls = [sg.Button("Play"), sg.Button("Pause"), sg.Button("Stop")]
layout = [[sg.FileBrowse(key="-MP3-", enable_events=True)], controls]
player = None
# Create the window
window = sg.Window("MP3 Player", layout)
# Create an event loop
while True:
event, values = window.read()
# End program if user closes window or
# presses the OK button
if event == "OK" or event == sg.WIN_CLOSED:
break
if event == "-MP3-":
player = vlc.MediaPlayer(values[\'-MP3-\'])
if event == "Play" and player is not None:
player.play()
if event == "Pause" and player is not None:
player.pause()
if event == "Stop" and player is not None:
player.stop()
window.close()
执行效果如下图所示
内容出处:,
声明:本网站所收集的部分公开资料来源于互联网,转载的目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。如果您发现网站上有侵犯您的知识产权的作品,请与我们取得联系,我们会及时修改或删除。文章链接:http://www.yixao.com/procedure/30262.html