Professional Documents
Culture Documents
Report submitted to
Guru Jambheshwar university of science and technology, Hisar
For the award of the degree
Of
Bachelor of Technology
In Information Technology
by
SRIJAN GUPTA
190010140058
1
DECLARATION
I certify that
a. The work in this report is original and has been done by me under
the udemy instructor.
b. I have followed the guidelines provided by the institute in preparing
the report.
c. I have confirmed to the norms and guidelines given in the Ethical
code of conduct of the institute.
d. Whenever I have used materials (data, theoretical analysis, figures,
and text) from other sources, I have given due credit to them by
citing them in the text of the report and giving their details in the
references. Further, I have taken permission from the copyright
owners of the sources, whenever necessary.
Signature of Student
2
CERTIFICATE
Abstract
3
In our daily life we see every next person have hobby of listening to
music. But as we know that the audio files are digital files. Therefore,
there is a need of a tool to run the digital files or in other words, play the
files. Thus, we need MP3 players. It is a device using to play MP3s and
other digital audio files.
This program will allow to play songs, music, and all MP3 files on desktop
or laptops. MP3 player using Python is a basic programming application
built using the programming language Python. It is a GUI program built by
the means of Python libraries Tkinter, Pygame and Mutagen.
4
CONTENTS
Cover Page 1
Declaration 2
Abstract 4
Chapter 2 Python 8
Chapter 5 OS module 14
Project 17
Conclusion 25
5
1.Introduction to GUI Applications
Advantages of GUI
2. It is easy to explore and find your way around the system using a
WIMP/ GUI interface.
6
4. There are usually a reasonable 'help' system included with WIMP
interface.
Disadvantages of GUI
1. GUIs take up a much larger amount of hard disk space than other
interfaces.
2.PYTHON
Python is a general purpose, dynamic, high-level, and interpreted
programming language. It supports Object Oriented programming
approach to develop applications. It is simple and easy to learn
and provides lots of high-level data structures.
o Data Science
o Date Mining
o Desktop Applications
o Console-based Applications
o Mobile Applications
o Software Development
o Artificial Intelligence
7
Python Basic Syntax
def func():
statement 1
statement 2
…………………
…………………
statement N
Python variables
8
Types of Operator
Loops
while loop
i=0
while i < 6:
i += 1
if i == 3:
continue
print(i
for loop
Executes a sequence of statements multiple times and abbreviates the code
that manages the loop variable.
9
nested loops
You can use one or more loop inside any another while, for or do..while
loop.
Python functions
my_function("Sweden")
my_function("India")
my_function()
my_function("Brazil")
Python Classes/Objects
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
p1 = Person("John", 36)
10
print(p1.name)
print(p1.age)
Python Iterators
An iterator is an object that can be iterated upon, meaning that you can
traverse through all the values.
print(next(myit))
print(next(myit))
print(next(myit)
Exception Handling
The try block lets you test a block of code for errors.
The finally block lets you execute code, regardless of the result of the try-
and except blocks.
try:
print(x)
except NameError:
print("Variable x is not defined")
except:
print("Something else went wrong")
Finally:
The finally block, if specified, will be executed regardless if the try block
raises an error or not.
11
try:
print(x)
except:
print("Something went wrong")
finally:
print("The 'try except' is finished")
Tkinter widgets
There are various widgets like button, canvas, checkbutton, entry, etc. that
are used to build the python GUI applications.
1.Button
12
The Button is used to add various kinds of buttons to the python
application.
2.canvas
The Canvas widget is used to draw shapes, such as lines, ovals, polygons
and rectangles, in your application
3.Checkbutton
The Checkbutton widget is used to display a number of options as
checkboxes. The user can select multiple options at a time.
4. Entry
The Entry widget is used to display a single-line text field for accepting
values from a user.
5. Frame
The Frame widget is used as a container widget to organize other widgets
6. Label
The Label widget is used to provide a single-line caption for other
widgets. It can also contain image.
7. Listbox
8. Menubutton
9. Menu
The Menu widget is used to provide various commands to a user. These
commands are contained inside Menubutton
10. Message
The Message widget is used to display multiline text fields for accepting
values from a user
13
Python Tkinter pack() method
widget.pack(options)
The grid() geometry manager organizes the widgets in the tabular form.
widget.grid(options)
The place() geometry manager organizes the widgets to the specific x and
y coordinates.
widget.place(options)
Syntax
14
4.Fundamentals of Pygame
import pygame
pygame.init()
screen = pygame.display.set_mode((400,500))
done = False
while not done:
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True
pygame.display.flip()
15
import pygame - This provides access to the pygame framework and
imports all functions of pygame.
5.OS Module
os.name()
This function provides the name of the operating system module that it
imports.
os.mkdir()
os.chdir()
os.rmdir()
os.error()
os.popen()
This function opens a file or from the command specified, and it returns a
file object which is connected to a pipe
os.close()
os.rename()
os.access()
This function uses real uid/gid to test if the invoking user has access to
the path.
17
6 PROJECT
import os
from tkinter.filedialog import askdirectory
import pygame
from mutagen.id3 import ID3
from tkinter import*
root= Tk()
root.minsize(600,600)
listofsongs=[]
realnames=[]
v= StringVar()
songlabel= Label(root, textvariable=v,width=35)
index = 0
def nextsong(event):
global index
index += 1
pygame.mixer.music.load(listofsongs[index])
pygame.mixer.music.play()
updatelabel()
def prevsong(event):
global index
index -= 1
pygame.mixer.music.load(listofsongs[index])
18
pygame.mixer.music.play()
updatelabel()
def stopsong(event):
pygame.mixer.music.stop()
v.set(" ")
def updatelabel():
global index
#global songname
v.set(listofsongs[index])
#return songname
def directorychooser():
directory = 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)
pygame.mixer.init()
pygame.mixer.music.load(listofsongs[0])
pygame.mixer.music.play()
directorychooser()
Label=Label(root,text="Srijan's music player")
Label.pack()
listbox = Listbox(root)
19
listbox.pack()
for items in listofsongs:
listbox.insert(0,items)
nextbutton=Button(root, text="next song")
nextbutton.pack()
previousbutton=Button(root, text="previous song")
previousbutton.pack()
stopbutton=Button(root, text="stop song")
stopbutton.pack()
nextbutton.bind("<Button-1>", nextsong)
previousbutton.bind("<Button-1>", prevsong)
stopbutton.bind("<Button-1>", stopsong)
songlabel.pack()
root.mainloop()
20
CONCLUSION
This project has really been a good start and informative. It has made us
understand and learn how things go on frontend.
The scope of this project is to polish our skills, entertainment purpose and
to accomplish good grades .
References
https://www.w3schools.com/
https://blog.openclassrooms.com/
https://www.javatpoint.com/
21
22