Myadvancejavaproject

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 15

A

Micro Project
on
“Music Player Using Java”
Submitted in partial fulfillment of the requirement for the award of
Diploma of Engineering
in
Computer Engineering
By

Pragati Bavaskar

Arpan Pandit

Dhiraj Chaudhari

Sarth Gawad

Mr.Nikhil Asolkar

Department of Computer

Engineering
December 2022
CERTIFICATE

VIVA COLLEGE OF DIPLOMA ENGINEERING &


TECHNOLOGY VIRAR (W)
2022-23
This is to certify that the micro project entitled “Music Player Using Java ” has been
submitted under the guidance of Mr. Nikhil Asolkar in partial fulfillment of the
requirement for the award of Diploma of Engineering in Computer Engineering from
Maharashtra State Board of Technical Education.

“Music Player Using Java”

GROUP MEMBERS

19-Pragati Bavaskar

25 – Arpan Pandit

26-Dhiraj Chaudhari

27- Sarth Gawad

Project Guide H.O. D


Mr.Nikhil Asolkar Mr. Nikhil Asolkar
INDEX

Sr. No. Name of the topic Page no.

PART –A PLAN

1 Brief Introduction 1

2 Aim of the Micro-Project 2

3 Resources Required 2

PART –B OUTCOMES

1 Brief Description 3

2 Aim of Micro-Project 4

3 Course Outcomes Integrated 4

4 Actual Procedure Followed 5

5 Actual Resources Used 8

6 Outputs of the Micro-Projects 9

7 Skill Developed/ learning out of this Micro-Project 10


AJP 22517, Sem V
“Music Player Using Java”

PART-A PLAN

1.0 Brief Introduction


Java is a class-based, object-oriented programming language that is designed to have as
few implementation dependencies as possible. It is a general-purpose programming
language intended to let application developers write once, run anywhere (WORA),
meaning that compiled Java code can run on all platforms that support Java without the
need for recompilation. Java applications are typically compiled to bytecode that can run
on any Java virtual machine (JVM) regardless of the underlying computer architecture.
The syntax of Java is similar to C and C++, but has fewer low-level facilities than either
of them. The Java runtime provides dynamic capabilities (such as reflection and runtime
code modification) that are typically not available in traditional compiled language

Java was originally developed by James Gosling at Sun Microsystems


(which has since been acquired by Oracle) and released in 1995 as a core component of
Sun Microsystems' Java platform. The original and reference implementation Java
compilers, virtual machines, and class libraries were originally released by Sun under
proprietary licenses. As of May 2007, in compliance with the specifications of the Java
Community Process, Sun had relicensed most of its Java technologies under the GNU
General Public License. Oracle offers its own HotSpot Java Virtual Machine, however
the official reference implementation is the OpenJDK JVM which is free open source
software and used by most developers and is the default JVM for almost all Linux
distributions.

Music Player lets you manage all your music files quickly and easily . This
audio player supports almost all types of mp3 , midi ,wav , flac raw aac files and other
audio formats . Easily browse and play music songs by genres , albums , artists , songs
and folder. Media is integral parts of our lives. We are creating media player using java to
handle all the music requirements of user.

James Gosling, Mike Sheridan, and Patrick Naughton initiated the Java
language project in June 1991. Java was originally designed for interactive television, but
it was too advanced for the digital cable television industry at the time. The language was
initially called Oak after an oak tree that stood outside Gosling's office. Later the project
went by the name Green and was finally renamed Java, from Java coffee, the coffee from
Indonesia. Gosling designed Java with a C/C++-style syntax that system and application
programmers would find familiar.

4
AJP 22517, Sem V
“Music Player Using Java”

2.0 AIM of Micro-Project

To Design a java program play music stored on machine and control it using various java
components.

3.0 Resources Required

Sr. No Name of Specification Qty Remarks


Resource
1. Computer Computer Intel dell RAM 8GB 1

Software Microsoft word


2.
1
Any other
Book
Resources
3. Used 1

5
“Music Player Using Java” AJP 22517, Sem V

PART-BOUTCOME

1.0 Brief Description

Java is a class-based, object-oriented programming language that is designed to have as


few implementation dependencies as possible. It is a general-purpose programming language
intended to let application developers write once, run anywhere (WORA), meaning that compiled
Java code can run on all platforms that support Java without the need for recompilation. Java
applications are typically compiled to bytecode that can run on any Java virtual machine (JVM)
regardless of the underlying computer architecture. The syntax of Java is similar to C and C++, but
has fewer low- level facilities than either of them. The Java runtime provides dynamic capabilities
(such as reflection and runtime code modification) that are typically not available in traditional
compiled language

Java was originally developed by James Gosling at Sun Microsystems (which has since been
acquired by Oracle) and released in 1995 as a core component of Sun Microsystems' Java platform.
The original and reference implementation Java compilers, virtual machines, and class libraries
were originally released by Sun under proprietary licenses. As of May 2007, in compliance with
the specifications of the Java Community Process, Sun had relicensed most of its Java technologies
under the GNU General Public License. Oracle offers its own HotSpot Java Virtual Machine,
however the official reference implementation is the OpenJDK JVM which is free open source
software and used by most developers and is the default JVM for almost all Linux distributions.

Music Player lets you manage all your music files quickly and easily . This audio
player supports almost all types of mp3 , midi ,wav , flac raw aac files and other audio formats
. Easily browse and play music songs by genres , albums , artists , songs and folder. Media is
integral parts of our lives. We are creating media player using java to handle all the music
requirements of user.

James Gosling, Mike Sheridan, and Patrick Naughton initiated the Java language project in
June 1991. Java was originally designed for interactive television, but it was too advanced for the digital
cable television industry at the time. The language was initially called Oak after an oak tree that stood
outside Gosling's office. Later the project went by the name Green and was finally renamed Java, from Java
coffee, the coffee from Indonesia. Gosling designed Java with a C/C++-style syntax that system and
application programmers would fi

6
“Music Player Using Java” AJP 22517, Sem V

2.0 AIM of Micro-Project

To Design a java program play music stored on machine and control it


using various java components.

3.0 Course Outcomes (CO)

a) Develop programs to handle events in Java Programming.


b) Develop programs using GUI Framework (AWT and Swing).

7
“Music Player Using Java” AJP 22517, Sem V

4.0 Procedure Followed

Code:-

package com.dataflair.mp3.dataflair.mp3musicplayer;
import javazoom.jl.player.Player;
import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.*;
public class MusicPlayer implements ActionListener {
JFrame frame;
JLabel songName;
JButton select;
JPanel playerPanel, controlPanel;
Icon iconPlay, iconPause, iconResume, iconStop;
JButton play, pause, resume, stop;
JFileChooser fileChooser;
FileInputStream fileInputStream;
BufferedInputStream bufferedInputStream;
File myFile = null;
String filename, filePath;
long totalLength, pauseLength;
Player player;
Thread playThread, resumeThread;
public MusicPlayer() {
initUI();
ons
addActionEvents();
playThread = new Thread(runnablePlay);
resumeThread = new Thread(runnableResume);
}
public void initUI() {
songName = new JLabel("", SwingConstants.CENTER);
select = new JButton("Select Mp3");
playerPanel = new JPanel();
controlPanel = new JPanel();

iconPlay = new ImageIcon("E:\music-player-java-code\Dhiraj-Mp3MusicPlayer\music-player-icons\play-button.png");


iconPause = new ImageIcon("E:\music-player-java-code\Dhiraj-Mp3MusicPlayer\music-player-icons\pause-button.png");
iconResume = new ImageIcon("E:\music-player-java-code\Dhiraj-Mp3MusicPlayer\music-player-icons\ resume-button/png");
iconStop = new ImageIcon("E:\music-player-java-code\Dhiraj-Mp3MusicPlayer\music-player-icons\stop-button.png");
play = new JButton(iconPlay);
pause = new JButton(iconPause);
resume = new JButton(iconResume);
stop = new JButton(iconStop);
playerPanel.setLayout(new GridLayout(2, 1));
playerPanel.add(select);
8
“Music Player Using Java” AJP 22517, Sem V
playerPanel.add(songName);
controlPanel.setLayout(new GridLayout(1, 4));
controlPanel.add(play);
controlPanel.add(pause);
controlPanel.add(resume);
controlPanel.add(stop);
play.setBackground(Color.WHITE);
pause.setBackground(Color.WHITE);
resume.setBackground(Color.WHITE);
stop.setBackground(Color.WHITE);
frame = new JFrame();
frame.setTitle("Dhiraj's Music Player");
frame.add(playerPanel, BorderLayout.NORTH);
frame.add(controlPanel, BorderLayout.SOUTH);
frame.setBackground(Color.white);
frame.setSize(400, 200);
frame.setVisible(true);
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void addActionEvents() {
select.addActionListener(this);
play.addActionListener(this);
pause.addActionListener(this);
resume.addActionListener(this);
stop.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource().equals(select)) {
fileChooser = new JFileChooser();
fileChooser.setCurrentDirectory(new File("E:\music-player-java-code\Dhiraj-Mp3MusicPlayer\songs"));
fileChooser.setDialogTitle("Select Mp3");
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
fileChooser.setFileFilter(new FileNameExtensionFilter("Mp3 files", "mp3"));
if (fileChooser.showOpenDialog(select) == JFileChooser.APPROVE_OPTION) {
myFile = fileChooser.getSelectedFile();
filename = fileChooser.getSelectedFile().getName();
filePath = fileChooser.getSelectedFile().getPath();
songName.setText("File Selected : " + filename);
}
}
if (e.getSource().equals(play)) {
if (filename != null) {
playThread.start();
songName.setText("Now playing : " + filename);
} else {
songName.setText("No File was selected!");
}
}
if (e.getSource().equals(pause)) {
if (player != null && filename != null) {
try {
pauseLength = fileInputStream.available();
player.close();

9
“Music Player Using Java” AJP 22517, Sem V
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
if (e.getSource().equals(resume)) {
if (filename != null) {
resumeThread.start();
} else {
songName.setText("No File was selected!");
}
}
if (e.getSource().equals(stop)) {
if (player != null) {
player.close();
songName.setText("");
}

}
Runnable runnablePlay = new Runnable() {
@Override
public void run() {
try {
fileInputStream = new FileInputStream(myFile);
bufferedInputStream = new BufferedInputStream(fileInputStream);
player = new Player(bufferedInputStream);
totalLength = fileInputStream.available();
player.play();
} catch (Exception e) {
e.printStackTrace();
}
}
};
Runnable runnableResume = new Runnable() {
@Override
public void run() {
try {

fileInputStream = new FileInputStream(myFile);


bufferedInputStream = new BufferedInputStream(fileInputStream);
player = new Player(bufferedInputStream);
fileInputStream.skip(totalLength - pauseLength);
player.play();
} catch (Exception e) {
e.printStackTrace();
}
}
};
public static void main(String[] args) {
MusicPlayer mp = new MusicPlayer();
}
}

10
“Music Player Using Java” AJP 22517, Sem V

5.0 Resources Required

Sr. No Name of Specification Qty Remarks


Resource
1. Computer Computer Intel dell RAM 8GB 1

Software Microsoft word


2.
1
Any other
Book
Resources
3. Used 1

11
“Music Player Using Java” AJP 22517, Sem V

6.0 Outputs of Micro-Projects

12
“Music Player Using Java” AJP 22517, Sem V

13
“Music Player Using Java” AJP 22517, Sem V

7.0 Skill Developed

We have finally built our mp3 music player in java. Now we can listen to any mp3 music on our desktop.
From this java project, we have learned how to integrate any extra library to the project, how to do file
operations, and how to create user interface components such as frame, panels, buttons, labels, filechooser,
etc with the help of AWT and Swing packages. Thus we build music player using Java and various GUI
components.

14

You might also like