python 制作簡單的音樂播放器
如你所見,功能很簡單。只有基本的播放,停止,甚至只針對一首歌曲,僅供初學者參考學習用。

代碼
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 制作簡單的音樂播放器的詳細內(nèi)容,更多關于python 音樂播放器的資料請關注好吧啦網(wǎng)其它相關文章!
相關文章:
1. 基于android studio的layout的xml文件的創(chuàng)建方式2. 解決Android studio xml界面無法預覽問題3. 詳解Android studio 動態(tài)fragment的用法4. 圖文詳解vue中proto文件的函數(shù)調(diào)用5. 什么是python的自省6. Spring Boot和Thymeleaf整合結合JPA實現(xiàn)分頁效果(實例代碼)7. Android如何加載Base64編碼格式圖片8. 使用Android studio查看Kotlin的字節(jié)碼教程9. Vuex localStorage的具體使用10. Vue封裝一個TodoList的案例與瀏覽器本地緩存的應用實現(xiàn)

網(wǎng)公網(wǎng)安備