Want to manually create a player that belongs to you, while practicing Python programming?
If you want, then act now!
Required libraries
Pygame
Tkinter
Mutagen
As for their use, you can browse through the documentation, if you want to do a more powerful player, then you must take a good look at Oh!
Design ideas
As version 0, we do not want to do too complex projects. Here are just a few features:
To display the MP3 file name in a directory in a ListBox
Displays the name of the currently playing song
Play a previous song
Play the next song
Stop playing
Get the MP3 file under the directory
Directly on the code!
Def directorychooser ():
directory = Tkinter.filedialog.askdirectory ()
Os.chdir (directory)
For files in Os.listdir (directory):
If Files.endswith ('. mp3 '):
Realdir = Os.path.realpath (Files)
Audio = ID3 (Realdir)
Realnames.append (audio[' TIT2 '].text[0])
Listofsongs.append (Files)
Print (Files)
pygame.mixer.init()pygame.mixer.music.load(listofsongs[0])pygame.mixer.music.play()
button-related functions
def nextsong (event):
Global index
If index < Len (listofsongs)-1:
Index + = 1
Else
index = 0;
Pygame.mixer.music.load (Listofsongs[index])
Pygame.mixer.music.play ()
Updatelabel ()
def previoussong (event):
Global index
If index > 0:
Index-= 1
Else
index = Len (listofsongs)-1
Pygame.mixer.music.load (Listofsongs[index])
Pygame.mixer.music.play ()
Updatelabel ()
def stopsong (event):
Pygame.mixer.music.stop ()
V.set ("")
Update the currently playing song name
Def Updatelabel ():
Global index
V.set (Realnames[index])
:
Small series have their own Python learning Exchange group, if you want to learn, you can add: 588+090+942 Whether you are small white or Daniel, small parts are welcome, and small series in the group will not regularly share dry goods, including a small series of their own finishing a 2018 of the latest learning materials and 0 Basic introductory tutorial , Welcome to beginner and advanced in the small partners
It's cool! Python uses 37 lines of code to create its own music player, attached to the source