0% found this document useful (0 votes)
7 views18 pages

Ajp Micro

The document is a project report on creating a music player using Java, aimed at fulfilling the requirements for a diploma in a technical field. It outlines the project's introduction, objectives, resources needed, and the actual procedure followed to develop the application, which supports various audio formats. The report emphasizes the skills developed through the project, including core Java knowledge, multithreading, and file handling.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views18 pages

Ajp Micro

The document is a project report on creating a music player using Java, aimed at fulfilling the requirements for a diploma in a technical field. It outlines the project's introduction, objectives, resources needed, and the actual procedure followed to develop the application, which supports various audio formats. The report emphasizes the skills developed through the project, including core Java knowledge, multithreading, and file handling.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

lOMoAR cPSD| 47350772

A PROJECT REPORT ON

“MUSIC PLAYER BY JAVA”

SUBMITTED IN PARTIAL FULFILMENT OF THE REQUIREMENTS


FOR THE AWARD OF

DIPLOMA IN

NAME OF THE DEPARTMENT

SUBMITTED TO

MAHARASTRA STATE BOARD OF TECHNICAL


EDUCATION, MUMBAI

SUBMITTED BY

STUDENT NAME ENROLLMENT NO


Sahil Namdev Desai 2212070033

GUIDED BY

Full name of Guide


lOMoAR cPSD| 47350772

INDEX

Sr. No. Name of the topic Page no.

PART –A PLAN

1 Brief Introduction 1

2 Aim of the Micro-Project 1

3 Resources Required 2

PART –B OUTCOME

1 Brief Description 3

2 Aim of Micro-Project 4

3 Course Outcomes Integrated 4

4 Actual Procedure Followed 5

5 Actual Resources Used 7

6 Outputs of the Micro-Projects 8

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


lOMoAR cPSD| 47350772

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 languages.

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.

1
lOMoAR cPSD| 47350772

AIM of Micro-Project

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

Resources Required

Sr. No Name of Resource Specification Qty Remarks


1 Computer 500GB HDD, 1
4 Gb RAM,
AMD
processor,
Windows 7 OS
lOMoAR cPSD| 47350772

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
languages.

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.

3
lOMoAR cPSD| 47350772
lOMoAR cPSD| 47350772

AIM of Micro-Project

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

Course Outcomes (CO)

1.Develop programs to handle events in Java Programming.

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

5
lOMoAR cPSD| 47350772

4.0 Actual Procedure Followed

Code:- import javax.swing.*;


import javax.sound.sampled.*;
import java.awt.*;
import java.awt.event.*;
import java.io.File;
import java.io.IOException;

public class MusicPlayer extends JFrame {

private JButton playButton, pauseButton, stopButton, loadButton;


private Clip audioClip;
private AudioInputStream audioStream;
private File audioFile;

public MusicPlayer() {
setTitle("Advanced Java Music Player");
setSize(400, 200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new FlowLayout());

playButton = new JButton("Play");


pauseButton = new JButton("Pause");
stopButton = new JButton("Stop");
loadButton = new JButton("Load");

add(playButton);
add(pauseButton);
add(stopButton);
add(loadButton);

// Disable the buttons until a file is loaded


pauseButton.setEnabled(false);
stopButton.setEnabled(false);
lOMoAR cPSD| 47350772

// Play Button Action


playButton.addActionListener(e -> playMusic());

// Pause Button Action


pauseButton.addActionListener(e -> pauseMusic());

// Stop Button Action


stopButton.addActionListener(e -> stopMusic());

// Load Button Action


loadButton.addActionListener(e -> loadMusicFile());

setVisible(true);
}

private void playMusic() {


if (audioClip != null) {
audioClip.start();
pauseButton.setEnabled(true);
stopButton.setEnabled(true);
playButton.setEnabled(false);
}
}

private void pauseMusic() {


if (audioClip != null && audioClip.isRunning()) {
audioClip.stop();
pauseButton.setText("Resume");
} else {
audioClip.start();
pauseButton.setText("Pause");
}
}

private void stopMusic() {


lOMoAR cPSD| 47350772

if (audioClip != null) {
audioClip.stop();
audioClip.setFramePosition(0); // Reset the clip to the beginning
pauseButton.setText("Pause");
playButton.setEnabled(true);
pauseButton.setEnabled(false);
stopButton.setEnabled(false);
}
}

private void loadMusicFile() {


JFileChooser fileChooser = new JFileChooser();
fileChooser.setDialogTitle("Select a Music File");
fileChooser.setFileFilter(new
javax.swing.filechooser.FileNameExtensionFilter("WAV files", "wav"));

int returnValue = fileChooser.showOpenDialog(this);


if (returnValue == JFileChooser.APPROVE_OPTION) {
audioFile = fileChooser.getSelectedFile();
try {
audioStream = AudioSystem.getAudioInputStream(audioFile);
audioClip = AudioSystem.getClip();
audioClip.open(audioStream);
playButton.setEnabled(true);
loadButton.setEnabled(false); // Disable load button after a file is loaded
} catch (UnsupportedAudioFileException | IOException |
LineUnavailableException ex) {
JOptionPane.showMessageDialog(this, "Error loading audio file: " +
ex.getMessage());
}
}
}

public static void main(String[] args) {


SwingUtilities.invokeLater(MusicPlayer::new);
}
}
lOMoAR cPSD| 47350772
lOMoAR cPSD| 47350772

Actual Resources Used

Sr. No Name of Resource Specification Qty Remarks

1 Computer 500GB HDD, 1


4 Gb RAM,
AMD processor,
Windows 7 OS

10
lOMoAR cPSD| 47350772

Outputs of Micro-Projects

Output:
lOMoAR cPSD| 47350772

12
lOMoAR cPSD| 47350772
lOMoAR cPSD| 47350772

14
lOMoAR cPSD| 47350772

Skill Developed

Thus we have build music player using Java and various GUI components.

 Core Java Knowledge: Writing this music player application will deepen your understanding of
core Java concepts such as object-oriented programming (OOP), classes, objects, methods,
inheritance, and exception handling.

 Multithreading: Handling real-time updates like song progress and time synchronization
requires knowledge of threads and how to manage multiple tasks concurrently (e.g., updating
the progress bar while playing the song).

 File Handling: You'll learn how to read and write files in Java, especially for interacting with
audio files (e.g., opening files with a FileChooser).
lOMoAR cPSD| 47350772

You might also like