0% found this document useful (0 votes)
33 views16 pages

Micoproject

Uploaded by

Sandip Thamke
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)
33 views16 pages

Micoproject

Uploaded by

Sandip Thamke
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/ 16

GOVERNMENT POLYTECHNIC , JINTUR

MICROPROJECT
Academic year:2024-25

TITLE OF THE PROJECT


Build a Program For Music Player Using Java

PROGRAM : Diploma In Computer Engineering


COURSE : Advanced Java Programming
COURSE CODE : 22517
GUIDE : Prof. Kale Sir

ROLL.NO. STUDENT NAME ENROLLMENT NO.


332 THAMKE SANDIP PANDURANG 2200940105
339 MATHPATI SHREENATH SOMNATH 2200940122
345 JADHAV ADITYA NARAYAN 2200940141
347 WADIKAR MUKESH SHRISHAILYA 2200940143
MAHARASHTRA STATE BOARD OF TECHNICAL
EDUCATION
Certificate
This is to certify that Mr./Ms. Thamke S.P., Mathpati S.S.,Jadhav
A.N.,Wadikar M.S. Roll No. 332, 339, 345, 347 of Fifth Semester of Diploma in
Computer Engineering of Institute, Government Polytechnic,Jintur (0094) has
completed the Micro Project satisfactorily in Subject Advanced Java
Programming for the academic year 2024-25 as prescribed in the curriculum.

Place: Jintur Enrollment No: 2200940105 ,2200940122,


2200940141,2200940143

Date: Exam Seat No:

Subject Teacher Head Of The Demartment

Principal

Seal of
Institution
3

INDEX

Sr.No. Contents Page No.

1 Acknowledgement 4

2 Annexure I 5-6

3 Annexure II 7

4 Program Code 8-12

5 Output 13-14

6 Conclusion 15

7 Reference 16
4

ACKNOWLEDGEMENT

We take this opportunity to express our deepest sense of gratitude and


sincere thanks to those who have helped us in completing this task

We express our sincere Thanks to our guide PROF.Kale Sir. Head Of The
COMPUTER Department. Who has given us valuable suggestion excellent
guidance, continues encouragement and taken keen interest in the completion of
this work. Her kind assistance and constant inspiration will always help us in our
future also.

We are thankful to principal sir, for encouraging us to undertake this project


and she has taken interest in making the project and report absolutely flawless

Credit goes to our friends' staff member of information technology


Department and the institute's library for their helps and timely assistance.
5

Annexure I
Micro-Project Proposal
Aims/Benefits of the Micro-Project : Build a Program For Music Player Using Java.
Course Outcomes Addressed:
1. Develop a program using GUI framework (AWT and SWING)
2. Develop programs to handle events in Java programming
Proposed Methodology :
1.Firstly we will select the microproject topic.
2.After selecting microproject topic we will gather the information about it from everywhere
such as online sites.
3.After gathering information we will start to write program for it.And by accomplishing this
methodology we will finish the microproject in easy way.
Literature Review: The development of a music player in Java is grounded in various well-
established technologies, ranging from multimedia libraries to GUI frameworks and file handling
mechanisms. Java’s versatility, combined with libraries like JavaFX, JLayer, and BasicPlayer,
provides a rich environment for creating music player applications. Literature in the field consistently
highlights the benefits of Java’s object-oriented nature, event-driven programming model, and cross-
platform capabilities, making it an ideal language for developing a portable, functional music player.
Action Plan :

Sr. Planned Planned Name of Responsible


Details of activity
No. Start date Finish date Team Members

Topic Selection and Algorithm Thamke Sandip P.


1 12/ OCT /2024 13/OCT/2024
writing Mathpati Shreenath S.

2 Information Gathering 14/ OCT /2024 20/OCT/2024 Jadhav Aditya N.


Wadikar Mukesh S.
3 Program Writing 26/ OCT /2024 21/OCT/2024
Resources Required:

Sr.No. Name of Resource/material Specifications Qty. Remarks

1 Interenet Service any 4

2 Computer/desktop/laptop Windows10pro,22H2 4
@3.20 @3.19GHz CPU
6

Names of Team Members with Roll No.


ROLL.NO. STUDENT NAME ENROLLMENT NO.
332 THAMKE SANDIP PANDURANG 2200940105
339 MATHPATI SHREENATH SOMNATH 2200940122
345 JADHAV ADITYA NARAYAN 2200940141
347 WADIKAR MUKESH SHRISHAILYA 2200940143
7

Annexure II
Micro-Project Report
Rationale :
A Java-based music player typically involves using multimedia libraries like JavaFX or third-
party APIs like JLayer, JavaZoom, or BasicPlayer to handle audio playback. By working with these
libraries, developers can deepen their understanding of how Java interacts with media formats and how
to manipulate files programmatically.
Aims/Benefits of the Micro-Project : Aim of this microproject is to Build a Program For
Music Player Using Java.
Course Outcomes Addressed:
1. Develop a program using GUI framework (AWT and SWING)
2. Develop programs to handle events in Java programming
Actual Methodology Followed :
To complete this we followed procedure as we firstly we were finding the microject topic and
after finding it, we decided to do it. After selecting microproject we gathered information about it
from everywhere as much as we visited online sites. Then we started to write program it take more
days than usual.
And finally the program also completed !
Actual Resources Used (Mention the actual resources used).

sr.
Name of Resource/material Specifications Qty. Remarks
No.

1 Interenet Service any 1

2 Computer/desktop/laptop Windows 10 pro,22H2, 1


@3.20 @3.19GHz CPU

Skill Developed / Learning outcome Of this Micro-Project:


By this microproject learnt to write simple ‘Java’ programs to use them in our day to day life
which will make our life easy.We also learnt the event handling of ‘Java’events in program and how
to use them.
Applications of this Micro-Project :
Developing our self music player is more efficient to use .
8

Program Code :

package jlay;

import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileFilter;
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.util.Duration;

public class Layer {


private MediaPlayer mediaPlayer;
private boolean isPaused = false;
private JSlider songSlider;
private Timer sliderTimer;

public Layer() {
// Initialize JavaFX (since we are using JavaFX for media playback)
JFXPanel fxPanel = new JFXPanel();

JFrame main = new JFrame("Enhanced Music Player");


main.setVisible(true);
main.setSize(400, 500);
main.setLayout(new FlowLayout());
main.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

// Create a menu bar


JMenuBar menuBar = new JMenuBar();
JMenu fileMenu = new JMenu("File");
JMenuItem openFolderMenuItem = new JMenuItem("Open Folder");
openFolderMenuItem.addActionListener(e -> openFolderDialog());
fileMenu.add(openFolderMenuItem);
menuBar.add(fileMenu);
main.setJMenuBar(menuBar);
9

// Play/Pause button (single button)


JButton playPauseButton = new JButton("Play");
playPauseButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
togglePlayPause(playPauseButton);
}
});
main.add(playPauseButton);

// Slider for song progress


songSlider = new JSlider(0, 100, 0);
songSlider.setPreferredSize(new Dimension(300, 50));
//songSlider.setPaintTicks(true);
//songSlider.setPaintLabels(true);
//songSlider.setMajorTickSpacing(10);
songSlider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (!songSlider.getValueIsAdjusting() && mediaPlayer != null) {
mediaPlayer.seek(Duration.seconds(songSlider.getValue()));
}
}
});
main.add(songSlider);

JButton stopButton = new JButton("Stop");


stopButton.addActionListener(e -> stopSong());
main.add(stopButton);
}

// Method to open folder dialog


private void openFolderDialog() {
JFileChooser folderChooser = new JFileChooser();
folderChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int result = folderChooser.showOpenDialog(null);
if (result == JFileChooser.APPROVE_OPTION) {
File selectedFolder = folderChooser.getSelectedFile();
selectSongFromFolder(selectedFolder);
}
}

// Method to select a song from the folder


private void selectSongFromFolder(File folder) {
10

File[] songs = folder.listFiles(new FileFilter() {


@Override
public boolean accept(File file) {
// Accept only mp3, m4a, and other audio files
return file.isFile() && (file.getName().endsWith(".mp3") ||
file.getName().endsWith(".m4a") || file.getName().endsWith(".wav"));
}
});

if (songs != null && songs.length > 0) {


String[] songNames = new String[songs.length];
for (int i = 0; i < songs.length; i++) {
songNames[i] = songs[i].getName();
}

// Show song selection dialog


String selectedSong = (String) JOptionPane.showInputDialog(null, "Select a song",
"Song Selection",
JOptionPane.PLAIN_MESSAGE, null, songNames, songNames[0]);

if (selectedSong != null) {
for (File song : songs) {
if (song.getName().equals(selectedSong)) {
playSong(song);
break;
}
}
}
} else {
JOptionPane.showMessageDialog(null, "No audio files found in the selected folder.");
}
}

// Method to play a song


private void playSong(File file) {
stopSong(); // Stop any currently playing song
Platform.runLater(() -> {
Media media = new Media(file.toURI().toString());
mediaPlayer = new MediaPlayer(media);

mediaPlayer.setOnReady(() -> {
songSlider.setMaximum((int) mediaPlayer.getTotalDuration().toSeconds());
startSliderTimer();
});
11

mediaPlayer.play();
});
}

// Method to toggle between play and pause


private void togglePlayPause(JButton playPauseButton) {
if (mediaPlayer != null) {
if (isPaused) {
mediaPlayer.play();
playPauseButton.setText("Pause");
isPaused = false;
} else {
mediaPlayer.pause();
playPauseButton.setText("Play");
isPaused = true;
}
} else {
JOptionPane.showMessageDialog(null, "No song selected!");
}
}

// Method to stop the song


private void stopSong() {
if (mediaPlayer != null) {
mediaPlayer.stop();
stopSliderTimer();
songSlider.setValue(0);
mediaPlayer = null;
}
}

// Method to update the slider based on the current playback time


private void startSliderTimer() {
sliderTimer = new Timer(1000, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (mediaPlayer != null) {
songSlider.setValue((int) mediaPlayer.getCurrentTime().toSeconds());
}
}
});
sliderTimer.start();
}
12

// Method to stop updating the slider when the song stops


private void stopSliderTimer() {
if (sliderTimer != null) {
sliderTimer.stop();
}
}

public static void main(String[] args) {


SwingUtilities.invokeLater(Layer::new);
}
}
13

Output :
14
15

Conclusion :

The enhanced music player program written in Java successfully


demonstrates how to leverage JavaFX and Swing to create a feature-rich, cross-
platform audio player. By integrating JavaFX’s MediaPlayer for handling multiple
audio formats such as MP3, WAV, and M4A, the program goes beyond basic MP3
playback and extends its usability for various audio types. The inclusion of a
graphical user interface (GUI) with a menu bar, a play/pause toggle button, and a
music progress slider improves user interaction and control over playback.
16

Reference :
Books :
1. Java: The Complete Reference by Herbert Schildt
2. JavaFX 8: Introduction by Example by Carl Dea, Mark Heckler, Gerrit Grunwald, José
Pereda, and Sean Phillips
Websites :
1. Oracle's JavaFX Documentation
2. JavaZoom (JLayer)

You might also like