Skip to content

Commit

Permalink
Merge pull request #293 from Craniace/main
Browse files Browse the repository at this point in the history
music player using python (Issue #264) under hacktoberfest 2024
  • Loading branch information
sudhanshu-77 authored Oct 27, 2024
2 parents c30d5e3 + 977dd89 commit a7f9938
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions Music plauyer in python
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

33 changes: 33 additions & 0 deletions Music player in python/music1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from tkinter import *
from tkinter import filedialog
from pygame import mixer

class 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()

0 comments on commit a7f9938

Please sign in to comment.