python 制作簡單的音樂播放器
如你所見,功能很簡單。只有基本的播放,停止,甚至只針對(duì)一首歌曲,僅供初學(xué)者參考學(xué)習(xí)用。
代碼
from tkinter import *from tkinter import filedialogfrom pygame import mixerclass MusicPlayer: def __init__(self, window ): window.geometry(’320x100’); window.title(’Iris Player’); window.resizable(0,0) Load = Button(window, text = ’Load’, width = 10, font = (’Times’, 10), command = self.load) Play = Button(window, text = ’Play’, width = 10,font = (’Times’, 10), command = self.play) Pause = Button(window,text = ’Pause’, width = 10, font = (’Times’, 10), command = self.pause) Stop = Button(window ,text = ’Stop’, width = 10, font = (’Times’, 10), command = self.stop) Load.place(x=0,y=20);Play.place(x=110,y=20);Pause.place(x=220,y=20);Stop.place(x=110,y=60) self.music_file = False self.playing_state = False def load(self): self.music_file = filedialog.askopenfilename() def play(self): if self.music_file: mixer.init() mixer.music.load(self.music_file) mixer.music.play() def pause(self): if not self.playing_state: mixer.music.pause() self.playing_state=True else: mixer.music.unpause() self.playing_state = False def stop(self): mixer.music.stop()root = Tk()app= MusicPlayer(root)root.mainloop()
以上就是python 制作簡單的音樂播放器的詳細(xì)內(nèi)容,更多關(guān)于python 音樂播放器的資料請(qǐng)關(guān)注好吧啦網(wǎng)其它相關(guān)文章!
相關(guān)文章:
1. php5.6不能擴(kuò)展redis.so的解決方法2. python 爬取嗶哩嗶哩up主信息和投稿視頻3. js實(shí)現(xiàn)貪吃蛇小游戲(加墻)4. 使用idea 去除 html 代碼前的行號(hào)和空行的方法詳解5. SpringBoot 開發(fā)提速神器 Lombok+MybatisPlus+SwaggerUI6. js實(shí)現(xiàn)跳一跳小游戲7. PHP設(shè)計(jì)模式(四)原型模式Prototype實(shí)例詳解【創(chuàng)建型】8. JVM之class文件結(jié)構(gòu)9. 10個(gè)提供免費(fèi)PHP腳本下載的網(wǎng)站10. Python編寫nmap掃描工具
