You are on page 1of 18

Music Player Using Python

Submitted by:

Mayank Kumar (1808210088)


Table of content

• What is Python?

• Difference between program and scripting language.

• History of Python

• What can I do with python

• Data type of python

• Music Player Application using Tkinter

• Approach

• MusicPlayer Class

• Data Type in Python


What is Python?

1 Python is a general purpose programming language that is often


applied in scripting roles.

2 So, Python is programming language as well as scripting language. 

3  Python is also called as Interpreted language


Difference between program and scripting language

Program Scripting

A program is executed (i.e. the source is first A script is interpreted


compiled, and the result of that compilation is
expected)

A program in general is a sequence of instructions A script is code written in a scripting language. A


written so that a computer can perform certain task. scripting language is nothing but a type of
programming language in which we can write code
to control another software application.
History

1 Invented in the Netherlands, early 90s by Guido Van Rossum.

Python was conceived in the late 1980s and its implementation was started in December 1989.
2

3 Python Is open sourced from the beginning.


What can I do with Python?

• System programming
• Graphical User Interface Programming
• Internet Scripting
• Component Integration
• Database programming
• Gaming, Images, XML, Robot and more
Data Type

• Python has many native data types. Here are the important ones:
• Booleans are either True or False.
• Numbers can be integers (1 or 2), float (1.1 or 1.2), fractions (1/2 and 2/3) or even complex numbers.
• Strings are sequences of Unicode characters, e.g. an HTML document
• Bytes and byte array
• Lists
• Tuples
• Dictionary
Music Player Application using python

In this project, we will create a Music Player Application in Python


using Tkinter and Pygame module.

In our daily life, we see every person has a hobby and that is listening to music. So in
order to listen to music, they all need a Music player(hardware or software) where they
can play their favorite songs. And we have to install this music player on our computer,
based on the Operating system i.e Windows, Macintosh, Android, Linux, etc. Then we can
listen to our favorite songs.
Libraries used for Music Player Application:

Now we will tell you about the Libraries we will use in our code :

1. Tkinter

We had already told you in the title of this page that we are going to use the Tkinter library, which is a
standard library for GUI creation. The Tkinter library is most popular and very easy to use and it comes
with many widgets (these widgets help in the creation of nice-looking GUI Applications).

To use all the functions of Tkinter you need to import it in your code and the command for the same is:

from tkinter import *


2. Pygame module :

Pygame is a Python module that works with computer graphics and sound libraries and is designed with the
power of playing with different multimedia formats like audio, video, etc. While creating our Music Player
application, we will be using Pygame's mixer.music module for providing different functionality to our music player
application that is usually related to the manipulation of the song tracks.

Command used to install the pygame module is:

pip install pygame

To use this module in your code you need to write this:

import pygame
Approach:-

1.First, we will select the folder which contains music files

2.Then we select the music file which we want to listen

3.We can do four operations; play, pause, unpause and


stop the music

4.Increase and decrease the volume


MusicPlayer Class :
1.  The playsong() Function
Now we will define the Play Song Function and the code is:

def playsong(self):

# Displaying Selected Song title

self.track.set(self.playlist.get(ACTIVE))

# Displaying Status

self.status.set("-Playing")

# Loading Selected Song

pygame.mixer.music.load(self.playlist.get(ACTIVE))

# Playing Selected Song

pygame.mixer.music.play()
 2.The stopsong() Function

The code snippet to stop the song:

def stopsong(self):

# Displaying Status

self.status.set("-Stopped")

# Stopped Song

pygame.mixer.music.stop()
3.The pausesong() Function

The code snippet to pause the song:

def pausesong(self):

# Displaying Status

self.status.set("-Paused")

# Paused Song

pygame.mixer.music.pause()
4.The unpausesong() Function

The code snippet to unpause the song:

def unpausesong(self):

# It will Display the Status

self.status.set("-Playing")

# Playing back Song

pygame.mixer.music.unpause()
Now here are some of the screenshots of our application:

The Folder named studytonight where the code file and folder for songs is placed looks like this:
Now the following screenshot is to show you how the application will look like:
Thank You

You might also like