Detailed Documentation of Java Coding for MP3 Player Project
VerifiedAdded on 2022/08/26
|7
|1269
|20
Homework Assignment
AI Summary
This document presents a comprehensive documentation of Java code for an MP3 player project. It meticulously details the danPlayer interface, which defines methods like play, stop, pause, and file handling. The Mp3Player class, implementing the danPlayer interface, is the core, inheriting and implementing the interface's methods with specific functionalities for an MP3 player. The code includes media player controls, file selection, and playlist management. Furthermore, the GUInterface class integrates the Mp3Player, linking it to a graphical user interface. The documentation covers class structure, method definitions, and variable declarations, providing a clear understanding of the project's architecture and functionality. The document also clarifies the relationship between the interface and the implementing class, emphasizing how the Mp3Player class inherits and defines the methods from the danPlayer interface. Finally, it provides a complete overview of the project with all the methods and classes used to create the MP3 player.

Running head: DOCUMENTATION OF CODING
DOCUMENTATION OF CODING
Enter name of the Student:
Enter name of the University:
Author note:
DOCUMENTATION OF CODING
Enter name of the Student:
Enter name of the University:
Author note:
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

1DOCUMENTATION OF CODING
Documentation of the Java Coding
There are two important parts of the coding present named danPlayer interface and
Mp3Player class. Another class present in this project is GUInterface where a part is present
related to the Mp3Player class. The danPlayer is the super class and the Mp3Player class is
the sub class. Since danPlayer is an interface, so Mp3Player class implements the danPlayer
interface, not extend it. The others explanation of these classes are discussed below which are
as follows:
danPlayer interface
Figure 1: Code of danPlayer interface
(Source: Created by author)
The above figure is the coding of the danPlayer class. It is an interface. Here, first we
initialize some methods which are play (), stop (), pause (), openFile (). All the methods are
void type which means they return null.
Documentation of the Java Coding
There are two important parts of the coding present named danPlayer interface and
Mp3Player class. Another class present in this project is GUInterface where a part is present
related to the Mp3Player class. The danPlayer is the super class and the Mp3Player class is
the sub class. Since danPlayer is an interface, so Mp3Player class implements the danPlayer
interface, not extend it. The others explanation of these classes are discussed below which are
as follows:
danPlayer interface
Figure 1: Code of danPlayer interface
(Source: Created by author)
The above figure is the coding of the danPlayer class. It is an interface. Here, first we
initialize some methods which are play (), stop (), pause (), openFile (). All the methods are
void type which means they return null.

2DOCUMENTATION OF CODING
There is a method named getCurrentTrackName () which is the string type. This
method is created to retrieve the current track name of the mp3 player. Another is Mute
method. By the setMute (Boolean mute) method, the Boolean value for the mute is stored and
by the getMute () method, the value of mute is retrieved. After this, another method which is
created is volume. By the setVolume(double volume) method, the value which is 0 to 1
stored and by the getVolume () method, the value is retrieved. There is another method
present named Time (). The setTime (Duration time) method is created to store the duration
time of the song and the getTime () method is retrieve the duration time of the song.
Another method is the getTotalTime (), by this the total time of the songs played in
the Mp3 Player can be retrieved. The next method is the openPlayList () by which the playlist
can be opened. In the getPlayList () method, a string type arraylist is present where the songs
name which are showed in the playlist, are stored. Next method is the playTrack (int
trackNo), by which it can be chosen which track in the playlist to play. Another method is the
restart (), by which the current track can be started to play.
For the getTime () and setTime () method the type is Duration, for this reason import
the javafx.util.Duration.
So in this interface, the methods which are present named play (), stop (), pause (),
openFile (),getCurrentTrackName (),setMute (Boolean mute), getMute (),setVolume(double
volume), getVolume (),setTime (Duration time), getTime(), getTotalTime (),openPlayList
(),getPlayList (),playTrack (int trackNo). All these methods are implemented by the
Mp3Player class.
There is a method named getCurrentTrackName () which is the string type. This
method is created to retrieve the current track name of the mp3 player. Another is Mute
method. By the setMute (Boolean mute) method, the Boolean value for the mute is stored and
by the getMute () method, the value of mute is retrieved. After this, another method which is
created is volume. By the setVolume(double volume) method, the value which is 0 to 1
stored and by the getVolume () method, the value is retrieved. There is another method
present named Time (). The setTime (Duration time) method is created to store the duration
time of the song and the getTime () method is retrieve the duration time of the song.
Another method is the getTotalTime (), by this the total time of the songs played in
the Mp3 Player can be retrieved. The next method is the openPlayList () by which the playlist
can be opened. In the getPlayList () method, a string type arraylist is present where the songs
name which are showed in the playlist, are stored. Next method is the playTrack (int
trackNo), by which it can be chosen which track in the playlist to play. Another method is the
restart (), by which the current track can be started to play.
For the getTime () and setTime () method the type is Duration, for this reason import
the javafx.util.Duration.
So in this interface, the methods which are present named play (), stop (), pause (),
openFile (),getCurrentTrackName (),setMute (Boolean mute), getMute (),setVolume(double
volume), getVolume (),setTime (Duration time), getTime(), getTotalTime (),openPlayList
(),getPlayList (),playTrack (int trackNo). All these methods are implemented by the
Mp3Player class.
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

3DOCUMENTATION OF CODING
Mp3Player class
Figure 2: Code for Mp3Player class
(Source: Created by author)
Mp3Player class
Figure 2: Code for Mp3Player class
(Source: Created by author)
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

4DOCUMENTATION OF CODING
Figure 3: Code for Mp3Player class
(Source: Created by author)
Figure 4: Code for Mp3Player class
(Source: Created by author)
The next class is the Mp3Player class which is implements the danPlayer class. It
means the danPlayer class is the super class and the Mp3Player is the sub class. So by
implementing the danPlayer class, the Mp3Player class inherits all the methods and variable
of the super class that is danPlayer class. Mp3Player class can change the methods with its
requirements.
In this class, two variables are taken. One is mediaPlayer with the type of
MediaPlayer and for this import the javafx.scene.media.MediaPlayer in the coding and
another is track with the type of File and for this import the java.io.File in the coding. This
track variable holds the current opened or selected track.
Figure 3: Code for Mp3Player class
(Source: Created by author)
Figure 4: Code for Mp3Player class
(Source: Created by author)
The next class is the Mp3Player class which is implements the danPlayer class. It
means the danPlayer class is the super class and the Mp3Player is the sub class. So by
implementing the danPlayer class, the Mp3Player class inherits all the methods and variable
of the super class that is danPlayer class. Mp3Player class can change the methods with its
requirements.
In this class, two variables are taken. One is mediaPlayer with the type of
MediaPlayer and for this import the javafx.scene.media.MediaPlayer in the coding and
another is track with the type of File and for this import the java.io.File in the coding. This
track variable holds the current opened or selected track.

5DOCUMENTATION OF CODING
In this class, all the methods such as play (), stop (), pause () and openFile () which
are inherited from the danPlayer interface are defined properly. By the method play (), the
songs are played. By the method stop (), the songs are stopped. By the method pause (), the
songs are paused. By the method openFile (), the songs which are selected are opened and
after that the selected are played.
The next part shows the window or the popup or the dialog box to browse and after
that open an mp3 file. In this part, a media object is used for this import the
scene.media.Media and for the JFileChooser, import two things, one is
javax.swing.JFileChooser and javax.swing.filechooser.FileNameExtensionFilter.
After this part, the remaining methods which are inherited from the danPlayer
interfaceare defined properly which are getCurrentTrackName (), setMute (), setVolume (),
getTime (), getMute (), getVolume (), setTime (), getTotalTime ().
After this the openPlayList () method is defined which has no body part. A string type
arraylist is declared in the getPlayList (), where the selected songs are showing in the playlist
and also return the songs list. In the method of playTrack (int trackNo), the track can be
chosen which the user can play in this time. After that, the method restart are defined where
the current track is first stopped then again played.
So in this class, the methods which are inherited named play (), stop (), pause (),
openFile (),getCurrentTrackName (),setMute (Boolean mute), getMute (),setVolume(double
volume), getVolume (),setTime (Duration time), getTime(), getTotalTime (),openPlayList
(),getPlayList (),playTrack (int trackNo). All these methods are defined in the Mp3Player
class.
In this class, all the methods such as play (), stop (), pause () and openFile () which
are inherited from the danPlayer interface are defined properly. By the method play (), the
songs are played. By the method stop (), the songs are stopped. By the method pause (), the
songs are paused. By the method openFile (), the songs which are selected are opened and
after that the selected are played.
The next part shows the window or the popup or the dialog box to browse and after
that open an mp3 file. In this part, a media object is used for this import the
scene.media.Media and for the JFileChooser, import two things, one is
javax.swing.JFileChooser and javax.swing.filechooser.FileNameExtensionFilter.
After this part, the remaining methods which are inherited from the danPlayer
interfaceare defined properly which are getCurrentTrackName (), setMute (), setVolume (),
getTime (), getMute (), getVolume (), setTime (), getTotalTime ().
After this the openPlayList () method is defined which has no body part. A string type
arraylist is declared in the getPlayList (), where the selected songs are showing in the playlist
and also return the songs list. In the method of playTrack (int trackNo), the track can be
chosen which the user can play in this time. After that, the method restart are defined where
the current track is first stopped then again played.
So in this class, the methods which are inherited named play (), stop (), pause (),
openFile (),getCurrentTrackName (),setMute (Boolean mute), getMute (),setVolume(double
volume), getVolume (),setTime (Duration time), getTime(), getTotalTime (),openPlayList
(),getPlayList (),playTrack (int trackNo). All these methods are defined in the Mp3Player
class.
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

6DOCUMENTATION OF CODING
GUInterface class
Figure: Code for GUInterface class
(Source: Created by author)
In this GUInterface class, there is also a part of Mp3Player class. In this part, first a
new mp3 player is created by making a new object of Mp3Player. After that the method
openFile () is used to show the open file dialog. After the file was opened then set the track
label text to the track name using the a_trackLabel.setText
(a_mediaPlayer.getCurrentTrackName ()).
The above classes named Mp3Player also GUInterface and interface named danPlayer
are described properly. There are many methods present in the danPlayer interface and the
Mp3Player class implements the danPlayer interface which means the sub class Mp3Player
class is inherited from the super class danPlayer interface. Since, the danPlayer is an interface
so the Mp3Player class implements the danplayer interface, not extends it. All the methods is
initialized in the danPlayer interface and they are defined in the Mp3Player class.
GUInterface class
Figure: Code for GUInterface class
(Source: Created by author)
In this GUInterface class, there is also a part of Mp3Player class. In this part, first a
new mp3 player is created by making a new object of Mp3Player. After that the method
openFile () is used to show the open file dialog. After the file was opened then set the track
label text to the track name using the a_trackLabel.setText
(a_mediaPlayer.getCurrentTrackName ()).
The above classes named Mp3Player also GUInterface and interface named danPlayer
are described properly. There are many methods present in the danPlayer interface and the
Mp3Player class implements the danPlayer interface which means the sub class Mp3Player
class is inherited from the super class danPlayer interface. Since, the danPlayer is an interface
so the Mp3Player class implements the danplayer interface, not extends it. All the methods is
initialized in the danPlayer interface and they are defined in the Mp3Player class.
1 out of 7

Your All-in-One AI-Powered Toolkit for Academic Success.
+13062052269
info@desklib.com
Available 24*7 on WhatsApp / Email
Unlock your academic potential
Copyright © 2020–2025 A2Z Services. All Rights Reserved. Developed and managed by ZUCOL.