Android Sample Project Report Documentation
Android Sample Project Report Documentation
Affiliated to
at
ARDENT Computech Pvt. Ltd.
Music Player – An Android App
BONAFIDE CERTIFICATE
Certified that this project report on ‘Music Player’ in Android is the bonafide work
of Avishek Gupta, Kundan Kumar, Nivesh Parashar and Rajesh Ray who
carried out the project work under my supervision.
Avishek Gupta
Kundan Kumar
Nivesh Parashar
Rajesh Ray
___________________ ______________________
Dr. Tapoash Saha Prof. Jaydeep Mondal
Institute of Management Study, Ardent Computech Pvt. Ltd.
Mukundapur, Kolkata Salt Lake, Kolkata
2
Music Player – An Android App
ACKNOWLEDGEMENT
The project “Music Player”would not have been possible without the constant guidance of our
guide Prof. Chandan Jana, Ardent Computech Pvt. Ltd. ,who guided us throughout this process
despite his busy schedule. We are immensely thankful to him for his valuable ideas on
improvement of the project.
We are also grateful to Prof. Dr. Tapoash Saha, our HOD, for all the help she provided. The
brainstorming sessions that we had during the project development process, led to serious
arguments and disagreements, but only for the betterment of the project.
BCA,
Institute of Management Study,
3rd Year,5thSemester, 2016
3
Music Player – An Android App
CONTENTS
NO TOPICS PAGE NO
1. Introduction 5
2. Music Player 5-6
Description 5
Scope of project 6
Implementation 6
3. Basic Concepts and Tools 7-11
4. Component Diagram 12
E-R Diagram 13
Data Flow Diagram 13
5. Test Result 14
6. Future Scope 15
8. Conclusion 29
9. References 29
10. Bibliography 30
4
Music Player – An Android App
§1. INTRODUCTION
‘Music Player’ is an Android utility app based on music or songs. We have developed this app in
Android using Android Studio (version 2.1). The minimum requirements for this app are a
Smartphone having Android (version - Ice Cream sandwich or later). We can further improve this
project by adding more interesting and user-friendly features to it. Introduction is just the first
step towards what is yet to be offer in the music player. Music is something which is like a part of
our life and we should keep it as natural as possible because it is nature’s way to interact, connect,
in most efficient way to deliver what is yet to be discovered through our music player which is
rigged with feature and much more yet to be implemented
In coming tomorrow. Because this just the begging with only and only progress in the mind and
satisfaction of the user the priority.
5
Music Player – An Android App
Description
Music Player is a little, minimal features, music player program with following simple
functionalities:
Additional features:
This project can be further improved with more features in the near future. Features like more file
types, Visualizer, Rating, Albums and etc.
Implementation
6
Music Player – An Android App
In Android Studio, we have implemented our app named ‘Music Player’ that will play music from
different storage location.
Introduction to Java
Java is a programming language created by James Gosling from Sun Microsystems (Sun) in 1991.
The first publicly available version of Java (Java 1.0) was released in 1995. Sun Microsystems
was acquired by the Oracle Corporation in 2010. Over time new enhanced versions of Java have
been released. The current version of Java is Java 1.7 which is also known as Java 7. From the
Java programming language, the Java platform evolved. The Java platform allows software
developers to write program code in other languages than the Java programming language and
still runs on the Java virtual machine. The Java platform is usually associated with the Java
virtual machine and the Java core libraries.
The Java virtual machine (JVM) is a software implementation of a computer that executes
programs like a real machine. The Java virtual machine is written specifically for a specific
operating system, e.g. for Linux a special implementation is required as well as for Windows.
A Java distribution comes typically in two flavors, the Java Runtime Environment (JRE) and
the Java Development Kit (JDK). The Java runtime environment (JRE) consists of the JVM and
the Java class libraries and contains the necessary functionality to start Java programs. The JDK
contains in addition the development tools necessary to create Java programs. The JDK consists
therefore of a Java compiler, the Java virtual machine, and the Java class libraries.
7
Music Player – An Android App
Characteristics of Java
The target of Java is to write a program once and then run this program on multiple operating
systems.
Java has the following properties:
Platform independent: Java programs use the Java virtual machine as abstraction and do not
access the operating system directly. This makes Java programs highly portable. A Java program
(which is standard complaint and follows certain rules) can run unmodified on all supported
platforms, e.g. Windows or Linux.
Object-orientated programming language: Except the primitive data types, all elements in
Java are objects.
Strongly-typed programming language: Java is strongly-typed, e.g. the types of the used
variables must be pre-defined and conversion to other objects is relatively strict, e.g. must be
done in most cases by the programmer.
Interpreted and compiled language: Java source code is transferred into the byte code format
which does not depend on the target platform. These byte code instructions will be interpreted
by the Java Virtual machine (JVM). The JVM contains a so called Hotspot-Compiler which
translates performance critical byte code instructions into native code instructions.
Automatic memory management: Java manages the memory allocation and de-allocation for
creating new objects. The program does not have direct access to the memory. The so-called
garbage collector deletes automatically objects to which no active pointer exists.
Android
Android is a software platform and operating system for mobile devices. Android is available as
open source. It allows developers to write managed code in the Java language, controlling the
device via Google-developed Java libraries.
Android SDK was released by Open Handset Alliance in the month of November of the year
2007. Android was actually developed using the kernel of Linux 2.6 and the highlighting features
of Android include the following:
• No fees for licensing, distribution and release approval
• GSM, 3G EDGE networks for telephony
• IPC message passing
8
Music Player – An Android App
Architecture of Android OS
The skeleton of Android framework and its constituents are shown in the following figure:
Applications Layer
Android ships with a set of core applications including an email client, SMS program, calendar,
maps, browser, contacts and others. All applications are built using the Java. Each of the
applications aims at performing a specific task that it is actually intended to do.
9
Music Player – An Android App
of the application framework as a set of basic tools with which a developer can build much more
complex tools.
Libraries Layer
The next layer contains the native libraries of Android. These shared libraries are all written in C
or C++, compiled for the particular hardware architecture used by the phone and preinstalled by
the phone vendor.
Android Runtime Layer
Android Runtime layer includes Dalvik Virtual Machine (DVM) and a set of core java libraries.
Every Android app gets its own instance of DVM. Dalvik has been written so that a device can
run multiple virtual machines efficiently and it executes files with. dex (Dalvik Executable
Format) extension optimized for minimum memory.
Components of Android
The basic components of an Android application include Activity, Broadcast Receiver, Service,
and Content Provider. Each of the above, which when used for any application, has to be declared
in the AndroidManifest.xml. The user interface of the component is determined by the Views. For
the communication among these basic components we use Intents and Intent filters which play
crucial role during app development.
Android
Applicatio
n
Broadcast Content
Activity Service
Receiver Provider
Figure: Android Components
Activity
An Activity is, fundamentally, an object that has a lifecycle. An Activity is a chunk of code that
does some work, as necessary. The work can include displaying a UI to the user, though it doesn't
have to as some Activities never display UIs. Typically, we designate one of our application's
Activities as the entry point to our application.
10
Music Player – An Android App
Broadcast Receiver
Broadcast Receiver is yet another type of component that can receive and respond to any of the
broadcast announcements.
Service
A Service is a body of code that runs in the background. It can run in its own process, or in the
context of another application's process, depending on its needs. Other components "bind" to a
Service and invoke methods on it via remote procedure calls. An example of a Service is a media
player; even when the user quits the media-selection UI, she probably still intends for her music
to keep playing. A Service keeps the music going even when the UI has completed.
Content Provider
Content Provider is a data storehouse that provides access to data on the device; the classic
example is the Content Provider that is used to access the user's list of contacts. Our application
can access data that other applications have exposed via a Content Provider, and we can also
define our own Content Providers to expose data of our own.
11
Music Player – An Android App
12
Music Player – An Android App
Level - 1 DFD
13
Music Player – An Android App
14
Music Player – An Android App
Player Screen
The future scope of Music Player is limitless. How? Allow me tell you the ongoing innovations in
Music Player: -
15
Music Player – An Android App
The main scope of the player is to deliver the maximum user satisfaction which the
user so richly deserver.
Scope is just the prospective that we hold as its highly like to only move forward
in future with progress as it is the only scope of the coming future is the future
scope of the project.
Change is the natures way to progress in the future with the scope of progress,
satisfaction, upgradation and revolution as this is only the future destination.
Development is a way to endure ones to stay in the race. In the prestnt existing
market condition.
Development is the key to be in the pace and it always will be . Because sooner or
later its yet to be rigged with more feature like visualizer, equalizer , widget which
will not only enhance your experience of music better than before but redefine it
in order to offer the pure experience without any interruption and it’s the begging
towards the search of more to accomplish more and more .In the distinct future.
package com.example.esu.musicplayer;
import android.content.Intent;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import java.io.File;
import java.util.ArrayList;
ListView listView;
String[] songName; //Store song name in songName
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_playlist);
listView=(ListView)findViewById(R.id.listView);
16
Music Player – An Android App
songName=new String[(mySongs.size())];
for(int i=0;i<mySongs.size();i++){
songName[i]=mySongs.get(i).getName().toString().replace(".mp3","");
}
ArrayAdapter<String> adp=new
ArrayAdapter<String>(getApplicationContext(),R.layout.songname_layout,R.id.textView,songN
ame);
listView.setAdapter(adp);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
startActivity(new Intent(getApplicationContext(),Player.class)
.putExtra("POSITION",i)
.putExtra("SONGLIST",mySongs)
);
}
});
17
Music Player – An Android App
Player.java :
package com.example.esu.musicplayer;
import android.content.Intent;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import java.io.File;
import java.util.ArrayList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_player);
seekBar=(SeekBar)findViewById(R.id.seekBar);
18
Music Player – An Android App
songCurrentTime=(TextView)findViewById(R.id.songCurrentTime);
songTotalTime=(TextView)findViewById(R.id.songTotalTime);
musicName=(TextView)findViewById(R.id.SongTitle);
buttonPlay.setOnClickListener(this);
buttonNext.setOnClickListener(this);
buttonPre.setOnClickListener(this);
buttonFB.setOnClickListener(this);
buttonFF.setOnClickListener(this);
Intent intent=getIntent();
Bundle bundle=intent.getExtras();
mySongs=(ArrayList) bundle.getParcelableArrayList("SONGLIST");
position=bundle.getInt("POSITION",0);
uri=Uri.parse(mySongs.get(position).toString() );
mediaPlayer=MediaPlayer.create(getApplicationContext(),uri);
mediaPlayer.start();
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
/**
* When current song get finish then change to next song
* */
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
if(songCurrentTime.getText().equals(songTotalTime.getText())){
//Stop Media Player and Release
mediaPlayer.stop();
mediaPlayer.release();
buttonPlay.setImageResource(R.drawable.btn_pause);
position=(position+1) % mySongs.size();
uri=Uri.parse(mySongs.get(position).toString() );
mediaPlayer=MediaPlayer.create(getApplicationContext(),uri);
mediaPlayer.start();
musicTitle();
}
}
/**
* When user starts moving the progress handler
* */
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// remove message Handler from updating progress bar
mHandler.removeCallbacks(mUpdateTimeTask);
}
/**
* When user stops moving the progress hanlder
* */
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
//mediaPlayer.seekTo(seekBar.getProgress());
mHandler.removeCallbacks(mUpdateTimeTask);
int totalDuration = mediaPlayer.getDuration();
int currentPosition = utils.progressToTimer(seekBar.getProgress(), totalDuration);
musicTitle();
}
/**
* Update timer on seekbar
* */
public void updateProgressBar() {
mHandler.postDelayed(mUpdateTimeTask, 100);
}
/**
* Background Runnable thread
* */
private Runnable mUpdateTimeTask = new Runnable() {
20
Music Player – An Android App
/**
* Music Title Method
*/
private void musicTitle(){
StringBuffer stringBuffer=new StringBuffer(uri.toString());
int lastSlashPosition=stringBuffer.lastIndexOf("/") + 1;
stringBuffer.replace(0,lastSlashPosition,"");
musicName.setText(stringBuffer.toString().replace(".mp3",""));
}
/**
* Player Buttton coding and logics
* @param view
*/
@Override
public void onClick(View view) {
int id=view.getId();
switch (id){
/**
* Play button click event
* plays a song and changes button to pause image
* pauses a song and changes button to play image
* */
case R.id.btnPlay:
if(mediaPlayer.isPlaying()){
mediaPlayer.pause();
buttonPlay.setImageResource(R.drawable.btn_play);
}
21
Music Player – An Android App
else{
mediaPlayer.start();
buttonPlay.setImageResource(R.drawable.btn_pause);
}
break;
/**
* Next button click event
* */
case R.id.btnNext:
//Stop Media Player and Release
mediaPlayer.stop();
mediaPlayer.release();
position=(position+1) % mySongs.size();
uri=Uri.parse(mySongs.get(position).toString() );
mediaPlayer=MediaPlayer.create(getApplicationContext(),uri);
mediaPlayer.start();
musicTitle();
break;
/**
* Previous button click event
* */
case R.id.btnPrevious:
//Stop Media Player and Release
mediaPlayer.stop();
mediaPlayer.release();
musicTitle();
break;
/**
* Forward button click event
* Forwards song specified seconds
* */
case R.id.btnForword:
// get current song position
currentPosition = mediaPlayer.getCurrentPosition();
// check if seekForward time is lesser than song duration
if(currentPosition + seekForwardTime <= mediaPlayer.getDuration()){
22
Music Player – An Android App
// forward song
mediaPlayer.seekTo(currentPosition + seekForwardTime);
}else{
// forward to end position
mediaPlayer.seekTo(mediaPlayer.getDuration());
}
break;
/**
* Backward button click event
* Backward song to specified seconds
* */
case R.id.btnBackword:
// get current song position
currentPosition = mediaPlayer.getCurrentPosition();
// check if seekBackward time is greater than 0 sec
if(currentPosition - seekBackwardTime >= 0){
// forward song
mediaPlayer.seekTo(currentPosition - seekBackwardTime);
}else{
// backward to starting position
mediaPlayer.seekTo(0);
}
break;
}
}
}
Utilities.java :
package com.example.esu.musicplayer;
/**
* Function to convert milliseconds time to
* Timer Format
* Hours:Minutes:Seconds
* */
public String milliSecondsToTimer(long milliseconds){
String finalTimerString = "";
String secondsString = "";
23
Music Player – An Android App
/**
* Function to get Progress percentage
* @param currentDuration
* @param totalDuration
* */
public int getProgressPercentage(long currentDuration, long totalDuration){
Double percentage = (double) 0;
// calculating percentage
percentage =(((double)currentSeconds)/totalSeconds)*100;
// return percentage
return percentage.intValue();
}
/**
* Function to change progress to timer
* @param progress -
* @param totalDuration
* returns current duration in milliseconds
* */
public int progressToTimer(int progress, int totalDuration) {
int currentDuration = 0;
totalDuration = (int) (totalDuration / 1000);
currentDuration = (int) ((((double)progress) / 100) * totalDuration);
24
Music Player – An Android App
§8. CONCLUSION
We have developed this app, keeping in mind that our app will redefine the experience for
the users seeking for because it’s something to saddle for . This app especially developed
for only one purpose is to deliver the pious nature of music which the user so richly
deserves to have to have in any given point of time in any given situation. Users can
access to their favorite songs from the playlist option anytime because we believe in
simplicity. User don’t have to trouble themselves to update their newly added songs
because it reads songs from both the internal and sd-card which is again one the key
features. This app can be further carried out with more features like visualizer, equalizer
and widgets, and many more. Probably alredy by now you know that it’s just the begging
with only conclusion to carve for more and in the coming future .
25
Music Player – An Android App
§9. REFERENCES
26
Music Player – An Android App
§10. BIBLIOGRAPHY
www.wikipedia.com
www.javatpoint.com/android-tutorial
www.tutorialspoint.com/android/
http://www.androidhive.info/2012/03/android-building-audio-player-tutorial/
27