Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 46

FLUTTER BASED MUSIC

PLAYER
19IT552- SOFTWARE ENGINEERING
LABORATORY
MINI PROJECT REPORT

SUBMITTED BY ,
Nandhini .R 2020060
Shahina Fathima 2020060

Visali .N 202006057

2022-2023

1
CERTIFICATE

This is to Certify that it is the bonafide work done by Nandhini .R ,


Shahina Fathima , Visali .N for their Mini Project on FLUTTER BASED
MUSIC PLAYER in the 19IT552 SOFTWARE ENGINEERING
LABORATORY at Mepco Schlenk Engineering College, Sivakasi during the
year 2022-2023.

.………………… …………………………

Staff in charge Head of the Department

Dr. J. MARUTHUPANDI, M.E., (Ph.D.) Dr.T. REVATHI, M.E., Ph.D.,

FACULTY INCHARGE HEAD OF THE DEPARTMENT


Associate Professor (Senior Grade), Senior Professor and Head,
Department of Information Technology, Department of Information Technology,
Mepco Schlenk Engineering College, Mepco Schlenk Engineering College,
Sivakasi. Sivakasi.

2
ACKNOWLEDGEMENT

We have taken efforts in this project. However, it would not have been possible
without the kind support and help of many individuals and our reputed institution
Mepco Schlenk Engineering College, Sivakasi. We would like to extend our sincere
thanks to our Principal Dr. S. Arivazhagan ME., PhD.

We would like to express my special gratitude and thanks to Dr.T.Revathi ME.,


PhD. Senior Professor & Head of the Department for giving us such a wonderful
experience.

We are highly indebted to Dr.J.MaruthuPandi ASP/IT, and Mrs.N.Malathy


AP(Sr.Grade) for their guidance and constant supervision as well as for providing
necessary information regarding the project & also for their support in completing
the project.

We would like to express our gratitude towards other teaching and non teaching
staff members of IT Department for their kind co-operation and encouragement
which help us in all means to complete this project successfully.

3
ABSTRACT

This project is about the mp3 music player application development using Android. The biggest
difference between the music player and existing applications is that it is completely free for users
to use. It will integrate the advantages of existing music players on the market, as far as possible to
mining out the existing music players' function, and then do the filtering in order to eliminate
function that not practical or low cost-effective. Also, it will be keep improved based on user
feedback. In addition, depending on the user's usage scenario, the music player will also add some
modes, such as driving mode and night mode, to allow users to use the application in any situation
or environment.

Moreover, the music player will have audio trim features, allowing users to trim the best part of
their favorite song into phone ringtone or alarm. On the other hand, the existing music players pay
less attention to the control of gestures. Therefore, the music player will solve the limitation by
adding more gestures and shake the phone feature for media control to make it more user-friendly
and humanity.

In a nutshell, the methodology for developing the mp3 music application used in this project is the
agile development cycle. The agile development cycle consists of six phases, which is requirements
analysis, planning, design, implementation or development, testing, and deployment. Due to the
iterative and flexible nature of this approach, it is able to effectively adapt to users with changing
requirements

4
TABLE OF CONTENTS

1.Introduction 6
1.1Purpose 6
1.2 Scope 6
1.3 Definitions, Acronyms and Abbreviations 7
1.4 References 7
1.5 Overview 7
2.Implementation/Coding 22
3..Screen Shots 41
4.Conclusion 46

5
1.Introduction

Android is an open-source software stack created for mobile phones and other devices . The
Android Open Source Project (AOSP) , led by Google, is tasked with the maintenance and
further development of Android. Many device manufacturers have brought to market devices
running Android, and they are readably available around the world. Android’s purpose is to
establish an open platform for developers to build innovative mobile apps. Three key components
work together to realize this platform. The Android Compatibility Program defines the technical
details of Android platform and provides tools used by OEMs to ensure that developers’ apps run
on a variety of devices . The Android SDK provides built-in tools that Developers use to clearly
state the device features their apps require. And Android Market shows apps only to those
devices that can properly run those . This software is for android operating system software,
users can easily for music software of play, convenient and quick, use simple UI realized the use
function, in this software music can free play, and you can use it to change the state of the mobile
phone, unique menu to the user perfect experience.

1.1 Purpose

MP3 players allow the user to play music, podcasts and so on anywhere. Music is easily
stored and managed on the MP3 player, including skipping tracks or, on some models,
arranging playlists. They are portable digital music players that play music as audio files,
such as MP3. In addition, most of these devices allow to store video, pictures, and to receive
radio and TV programs (podcasting). Earphones and external speakers are the typical output
devices delivering sound to the listener.

1.2 Scope
The "Flutter Based Music Player" is a flutter-based mobile application that helps people
to listen to music from the internet which is already streamed and they can add favorites
to it and make playlists too. The additional requirement is to record the audio while
listening and save it in internal memory, it can be used in offline mode. The application
should be free to download in the form of APK file.

Users can access the music that is available on the internet and listen to them. we can
listen to music in offline mode by recording.

Furthermore, the software needs the Internet to fetch and display results. All system
information is maintained in a database, which is located on a web server. Users can
download it from the play store and search for the songs they wish to listen to, all they
need is an internet facility available during all of this process.

6
1.3 ACRONYMS AND ABBREVATION

ACROMYMS ABBERVATIONS

 APPS Applications
 CPU Central Processing Unit
 IOS iPhone Operating System
 MV Music Video
 MP3 MPEG 1Audio Layer 3
 MP4 MPEG Layer 4
 UI User Interface
 UTAR Universiti Tunku Abdul Rahman
 XML Full Extensible Markup Lnguage
 APK Android Applicaton Package

1.4 References

[1] https://www.youtube.com/watch?v=__Yardq8bmI
Coding tony
[2] https://nevonprojects.com/media-player-project/
Nevon projects, selection, and spec preparation.

1.5 Overview

Development Environment and Tool:

Android SDK

The Android software development kit (SDK) includes a comprehensive set of development
tools. These include a debugger, libraries, a handset emulator (based on QEMU), documentation,
sample code, and tutorials. Currently supported development platforms include computers
running Linux (any modern desktop Linux distribution), Mac OS X 10.4.9 or later, Windows XP
or later. The officially supported integrated development environment (IDE) is Eclipse (currently
3.5 or 3.6) using the Android Development Tools (ADT) Plug-in, though developers may use any
text editor to edit Java and XML files then use command line tools (Java Development Kit and

7
Apache Ant are required) to create, build and debug Android applications as well as control
attached Android devices (e.g., triggering a reboot, installing software package(s) remotely)

The Android open-source software stack consists of Java applications running on a Java-based,
object-oriented application framework on top of Java core libraries running on a Dalvik virtual
machine featuring JIT compilation. Libraries written in C include the surface manager, Open
Core media framework, SQLite relational database management system, OpenGL ES 2.0 3D
graphics API, WebKit layout engine, SGL graphics engine, SSL, and Bionic libc. The Android
operating system, including the Linux kernel, consists of roughly 12 million lines of code
including 3 million lines of XML, 2.8 million lines of C, 2.1 million lines of Java, and 1.75
million lines of C++.

SQLite

SQLite is an ACID-compliant embedded relational database management system contained in a


relatively small C programming library. The source code for SQLite is in the public domain and
implements most of the SQL standard. In contrast to other databases, SQLite is not a separate
process that is accessed from the client application, but an integral part of it.

SQLite uses a dynamically and weakly typed SQL syntax that does not guarantee the domain
integrity. SQLite is a multitasking database concerning reads. Writes can be done only one-at-a-
time. It is a popular choice for local/client storage on web browsers. It has many bindings to
programming languages. It is arguably the most widely used database engine, as it is used today
by several widespread browsers, operating systems, embedded systems among others.

System Analysis and Design:

System Analysis

1.Function Division:
Music player in general are divided into two parts: part of it is the music of users to
play, and the other part of it is to mobile phone user mode, and the control of the situation
with the simplest method shows to users of the perfect play experience.

2. Functional Description:
(1)User-oriented function Song list: users can play list of the definition, still can scan all
import, this simplified the user needs, personalized Settings, allowing the UI experience
more perfect.

8
Fig :1.5-1 Site Diagram

Proposed Approach:

When the user starts the application, they can select two types of the main action of
the application. The main action is divided into the music player and mp3 cutter. The first case is
a music player, where users can select a song they want to listen to under the "My music"
fragment and click it to play. In the music playing interface, users have a variety of options for
action which are playing as driver mode, media control with shaking, media control with the
gesture, media control with the icon button. The second case is an mp3 cutter. After the user
selects the song he or she wants to trim, the application will start to trim the music and save it to
the mobile device. At this point, the application will ask the user if they want to set the trimmed
audio to ringtone and then finish the action. After the completion of the action, the user can
choose whether to exit the application or not, if "no" back to select action interface, if "yes"
terminate the application

9
Fig 1.1-2 Proposed System Design

Diagrams:

10
Usecase Diagram

Fig 1.1-3 Usecase Diagram

Activity Diagram:

11
Fig: 1.1-4 Activity Diagram

The user starts the application and then it will go to the home page which is the "My music"
page. The application will read the device's local songs and generate a playlist. After that, the
user selects the song and plays it, the page will jump into the playing music interface, where the
user is allowed to control the music. Playing modes are allowed to control music play orders
12
which are shuffle playback, single cycle, and normal playback. Moreover, the user can also skip
to the next song, back to the previous song and play or pause the current music to control music.
Lastly, the user can enable the driver mode to play the song.

Audio Trim in Activity Diagram:

Fig: 1.1-6 Audio Trim in Activity Digram

In order to cut the MP3 song, the user needs to select an MP3 song to be trim after entering the
audio trim page. After that, the user can drag the progress bar to set the start and end times. A
dialog box will pop up after successfully trimmed the song to ask the user whether to set the
trimmed song as the ringtone. If the user agrees, the app will successfully set the ringtone and
13
end the activity. If users don't want to be set as a ringtone, they can click on "No" to end the
activity.

Methodology and Tools


Design Specifications:

Methodology

In this project, the agile development cycle will be used to guide the development process. The
reason for using agile methods is that mobile applications have a short software life cycle and
rapidly changing technologies, so users will constantly change their requirement and needs in
response to technological changes. Therefore, the agile development cycle are more suitable for
android application development because of iterative and flexible, so it can adapt effectively to
changing customers.

Requirement analysis:

At this stage, we will review existing MP3 music players on the market. After the review, we
14
will find out what current users need and idea to improve the existing music players and collect
their comments and suggestions for further analysis.

Planning:

In the planning stage, we should first try to explore out the features that the music player can
have. Next, we will eliminate the features that users feel no really useful or low cost-effective.
Finally, each feature is prioritized and assigned to an iteration.

Design:

The design stage is prepared according to the requirements of users. Since there are many details
and problems encountered during development to be considered for each feature. Therefore, we
will discuss and formulate solutions and test strategies to verify the product at this stage.

Implementation or Development:

During the development phase, we will iteratively implement each of the features listed during
the planning phase. At this stage, there will be many setbacks and obstacle, so the team needs to
constantly overcome these obstacles. Moreover, we will prioritize the most important features
and need to make intelligent trade-offs between the depth of completeness of a single feature and
the breadth of implementation of multiple features.

Testing

In this stage, we will test the performance of each feature in order to check whether it meets the
requirements of users. For example, we will test whether the application can be properly installed
and run on a real device, and check whether any errors occur in the running process and each
feature is up to standard

Deployment:

In this final phase, we will begin to deliver this application to the customer. For instance, we will
upload this MP3 music player application in the Google Play Store, or posting download links on
Utar Confession which is on Facebook in order to allow UTAR students to use it. In addition, we
will anticipate that users will encounter unpredictable problems when using the player in this
process, so we will solve these problems in a future version.

15
User requirements:

Functional Requirements:
 Able to import the MP3 format files on the device into the music player
 Able to play audio files smoothly
 Able to download or listen to the song by searching for the name of the song,
album, or artist
 Driving mode
 Night mode
 Songs in playlists can be quickly searched and filtered through the alphabet and
search bar

Non-functional Requirements:
 Simplify user interface
 Optimize the design to display the information in a better way

System Performance Definition:

1. Hardware/Software Variation:

The MP3 music player application needs to ensure the application can work and installed
properly and smoothly on different devices. For example, the hardware and operating system of
each phone will be different, just like Oppo and Huawei phone is ColorOS and EMUI based on
android respectively, so need to test on different devices. In addition, the application should
adapt to different devices to ensure that no errors occur during execution to avoid different
results on different devices.

2. App in background:

Since this project is developing a music player, the running state of this application in the
background is very important. If it does not work properly in the background, this will cause the
user to have to input data from scratch or restart the application when retrieving the application.

16
Functional Requirements:

Functional requirements 1.1


ID: FR1
TITLE: Download mobile application
DESC: A user should be able to download the mobile application through APK file.
The application should be free to download.
RAD: In order for the user to download the APK file.
DEP: None
Functional requirements 1.2
ID:FR2
TITLE: User registration-Mobile application
DESC: Given that a user has downloaded the APK file,then the user should be able to register
throughthe mobile application.The user must provide user-name,password and e-mail address.
RAD: In order for the user to register on the mobile application.
DEP: FR1
requirements 1.3
ID: FR3
TITLE: User log-in - Mobile application
DESC: Given that a user has registered, then the user should be able to log in to the mobile
application.
The log-in information will be stored on the phone and in the future the user should be logged in
automatically.
RAT: In order for a user to register on the mobile application.
DEP: FR1,FR2.
Functional requirements 1.4
ID: FR4
TITLE: Retrieve password
DESC: Given that a user has registered, then the user should be able to retrieve his/her password
by e-mail.
RAT: In order for a user to retrieve his/her password.
DEP: FR1
Functional requirement 1.5
ID: FR5
17
TITLE: Song Search
DESC: Given that a user is logged in to the mobile application, then the first page that is shown
should be the search page. The user should be able to search for a song according to search
options..
RAT: For a user to search for a song
DEP: FR4
Functional requirement 1.6
ID: FR6
TITLE: Play song
DESC: The user should be able to listen to the song by clicking the play button available in the
application.
RAT: For a user to play a song
DEP: FR5
Functional requirement 1.7
ID: FR7
TITLE: Pause song
DESC: The user should be able to pause the song by clicking the pause button available in the
application.
RAT: For a user to pause a song
DEP: FR6
Functional requirement 1.8
ID: FR8
TITLE: Increase volume
DESC: The user should be able to increase the volume of the song by adjusting the volume
button available in the application.
RAT: For a user to increase the volume of the song.
DEP: FR7
Functional requirement 1.9
ID: FR9
TITLE: Decrease volume
DESC: The user should be able to decrease the volume of the song by adjusting the volume
button available in the application.
RAT: For a user to decrease the volume of the song.

18
DEP: FR8
Functional requirement 1.10
ID: FR10
TITLE: Add to favourites
DESC: The user should be able to add favourites by clicking the favourites button which is
available in all the songs in the application.
RAT: For a user to add favourites
DEP: FR9
Functional requirement 1.11
ID: FR11
TITLE: Create playlist
DESC: The user should be able to create playlists with their own desired songs available in the
music player.
RAT: For a user to create playlist.
DEP: FR10
User Class 2-Administrator
Functional requirement 2.1
ID:FR6
Feature:Manage the app
In order to manage and administer the system.
Functional requirements 2.2
ID:FR7
Feature:Checking the app
In order to check the app and resolve the problems if any.
Functional requirements 2.2
ID:FR7
Feature:Maintain the app
In order to maintain the app in interval of time and release a new update or version.
Design constraints
This section includes the design constraints on the software caused by the hardware.

Application Memory Usage

19
ID:QR1
TAG:Application memory usage
GIST:The amount of Operating System memory occupied by the application.
METER:Observation done from the performance log during testing.
Operate System:DEFINED:The mobile Operating System which the application
is running on. Example: Android.
3.4 Software system attributes
This requirements in this section specify the required availability,maintainability and portability
of the software system.
Availability
ID:QR2
TAG:System Availability
GIST:The availability of the system when it is used.
SCALE:The average system availability.
WISH:100% of the time.
ID:QR3
TITLE:Internet Connection
DESC:The application should be connected to the Internet.
RAT:In order for the application to communicate with the database.
DEP:none
Maintainability
ID:QR5
TITLE:Application Extendibility
DESC:The application should be easy to extend.The code should be written in a way that it
favors implementation of new functions.
ID:QR1
TAG:Application memory usage
GIST:The amount of Operating System memory occupied by the application.
METER:Observation done from the performance log during testing.
Operate System:DEFINED:The mobile Operating System which the application
is running on. Example: Android.

Software system attributes

20
This requirements in this section specify the required availability,maintainability and portability
of the software system.
Availability
ID:QR2
TAG:System Availability
GIST:The availability of the system when it is used.
SCALE:The average system availability.
WISH:100% of the time.
ID:QR3
TITLE:Internet Connection
DESC:The application should be connected to the Internet.
RAT:In order for the application to communicate with the database.
DEP:none
Maintainability
ID:QR5
TITLE:Application Extendibility
DESC:The application should be easy to extend.The code should be written in a way that it
favors implementation of new functions.

21
IMPLEMENTATION
CODING:

AudioModel.java

package com.example.musicplayer;

import java.io.Serializable;

public class AudioModel implements Serializable {


String path;
String title;
String duration;

public AudioModel(String path, String title, String


duration) {
this.path = path;
this.title = title;
this.duration = duration;
}

public String getPath() {


return path;
}

public String getTitle() {


return title;
}

public String getDuration() {


return duration;
}

MainActivity.java

package com.example.musicplayer;

import android.Manifest;
import android.annotation.SuppressLint;
import android.content.pm.PackageManager;
22
import android.database.Cursor;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.io.File;
import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {


// Instantiating the MediaPlayer class

RecyclerView recyclerView;
TextView noMusicTextView;
ArrayList<AudioModel> songsList = new ArrayList<>();

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

recyclerView = findViewById(R.id.recycler_view);
noMusicTextView = findViewById(R.id.no_songs_text);

if(!checkPermission()){
requestPermission();
return;
}

String[] projection = {
MediaStore.Audio.Media.TITLE,
MediaStore.Audio.Media.DATA,
MediaStore.Audio.Media.DURATION
};
23
String selection = MediaStore.Audio.Media.IS_MUSIC +" != 0";

@SuppressLint("Recycle") Cursor cursor =


getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_
URI,projection,selection,null,null);
while(cursor.moveToNext()){
AudioModel songData = new
AudioModel(cursor.getString(1),cursor.getString(0),cursor.getString(2));
if(new File(songData.getPath()).exists())
songsList.add(songData);
}

if(songsList.size()==0){
noMusicTextView.setVisibility(View.VISIBLE);
}else{
//recyclerview
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(new
MusicListAdapter(songsList,getApplicationContext()));
}

boolean checkPermission(){
int result = ContextCompat.checkSelfPermission(MainActivity.this,
Manifest.permission.READ_EXTERNAL_STORAGE);
return result == PackageManager.PERMISSION_GRANTED;
}

void requestPermission(){
if(ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this,Ma
nifest.permission.READ_EXTERNAL_STORAGE)){
Toast.makeText(MainActivity.this,"READ PERMISSION IS
REQUIRED,PLEASE ALLOW FROM
SETTTINGS",Toast.LENGTH_SHORT).show();
}else
ActivityCompat.requestPermissions(MainActivity.this,new String[]
{Manifest.permission.READ_EXTERNAL_STORAGE},123);
}

@Override
24
protected void onResume() {
super.onResume();
if(recyclerView!=null){
recyclerView.setAdapter(new
MusicListAdapter(songsList,getApplicationContext()));
}
}
}

MusicListAdapter.java

package com.example.musicplayer;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;

public class MusicListAdapter extends


RecyclerView.Adapter<MusicListAdapter.ViewHolder>{

ArrayList<AudioModel> songsList;
Context context;

public MusicListAdapter(ArrayList<AudioModel>
songsList, Context context) {
this.songsList = songsList;
this.context = context;
}

@NonNull
@Override
25
public ViewHolder onCreateViewHolder(@NonNull ViewGroup
parent, int viewType) {
View view =
LayoutInflater.from(context).inflate(R.layout.recycler_
item,parent,false);
return new ViewHolder(view);
}

@Override
public void
onBindViewHolder(MusicListAdapter.ViewHolder holder,
@SuppressLint("RecyclerView") int position) {
AudioModel songData = songsList.get(position);
holder.titleTextView.setText(songData.getTitle());

if(MyMediaPlayer.currentIndex==position){
holder.titleTextView.setTextColor(Color.parseColor("#FF
0000"));
}else{
holder.titleTextView.setTextColor(Color.parseColor("#00
0000"));
}

holder.itemView.setOnClickListener(v -> {
//navigate to another acitivty

MyMediaPlayer.getInstance().reset();
MyMediaPlayer.currentIndex = position;
Intent intent = new
Intent(context,MusicPlayerActivity.class);
intent.putExtra("LIST",songsList);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);

});

@Override
public int getItemCount() {
return songsList.size();
}

public static class ViewHolder extends


26
RecyclerView.ViewHolder{

TextView titleTextView;
ImageView iconImageView;
public ViewHolder(View itemView) {
super(itemView);
titleTextView =
itemView.findViewById(R.id.music_title_text);
iconImageView = itemView.findViewById(R.id.icon_view);
}
}
}

MusicPlayerActivity.java

package com.example.musicplayer;

import android.annotation.SuppressLint;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.os.Handler;
import android.widget.ImageView;
import android.widget.SeekBar;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import java.io.IOException;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;

public class MusicPlayerActivity extends


AppCompatActivity {

TextView titleTv,currentTimeTv,totalTimeTv;
SeekBar seekBar;
ImageView pausePlay,nextBtn,previousBtn,musicIcon;
ArrayList<AudioModel> songsList;
AudioModel currentSong;
MediaPlayer mediaPlayer = MyMediaPlayer.getInstance();
int x=0;

27
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_music_player);

titleTv = findViewById(R.id.song_title);
currentTimeTv = findViewById(R.id.current_time);
totalTimeTv = findViewById(R.id.total_time);
seekBar = findViewById(R.id.seek_bar);
pausePlay = findViewById(R.id.pause_play);
nextBtn = findViewById(R.id.next);
previousBtn = findViewById(R.id.previous);
musicIcon = findViewById(R.id.music_icon_big);

titleTv.setSelected(true);

songsList = (ArrayList<AudioModel>)
getIntent().getSerializableExtra("LIST");

setResourcesWithMusic();

MusicPlayerActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
if(mediaPlayer!=null){
seekBar.setProgress(mediaPlayer.getCurrentPosition());
currentTimeTv.setText(convertToMMSS(mediaPlayer.getCurr
entPosition()+""));

if(mediaPlayer.isPlaying()){
pausePlay.setImageResource(R.drawable.ic_baseline_pause
_circle_outline_24);
musicIcon.setRotation(x++);
}else{
pausePlay.setImageResource(R.drawable.ic_baseline_play_
circle_outline_24);
musicIcon.setRotation(0);
}

}
new Handler().postDelayed(this,100);
}
});

28
seekBar.setOnSeekBarChangeListener(new
SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int
progress, boolean fromUser) {
if(mediaPlayer!=null && fromUser){
mediaPlayer.seekTo(progress);
}
}

@Override
public void onStartTrackingTouch(SeekBar seekBar) {

@Override
public void onStopTrackingTouch(SeekBar seekBar) {

}
});

void setResourcesWithMusic(){
currentSong =
songsList.get(MyMediaPlayer.currentIndex);

titleTv.setText(currentSong.getTitle());

totalTimeTv.setText(convertToMMSS(currentSong.getDurati
on()));

pausePlay.setOnClickListener(v-> pausePlay());
nextBtn.setOnClickListener(v-> playNextSong());
previousBtn.setOnClickListener(v-> playPreviousSong());

playMusic();

private void playMusic(){


29
mediaPlayer.reset();
try {
mediaPlayer.setDataSource(currentSong.getPath());
mediaPlayer.prepare();
mediaPlayer.start();
seekBar.setProgress(0);
seekBar.setMax(mediaPlayer.getDuration());
} catch (IOException e) {
e.printStackTrace();
}

private void playNextSong(){

if(MyMediaPlayer.currentIndex== songsList.size()-1)
return;
MyMediaPlayer.currentIndex +=1;
mediaPlayer.reset();
setResourcesWithMusic();

private void playPreviousSong(){


if(MyMediaPlayer.currentIndex== 0)
return;
MyMediaPlayer.currentIndex -=1;
mediaPlayer.reset();
setResourcesWithMusic();
}

private void pausePlay(){


if(mediaPlayer.isPlaying())
mediaPlayer.pause();
else
mediaPlayer.start();
}

@SuppressLint("DefaultLocale")
public static String convertToMMSS(String duration){
long millis = Long.parseLong(duration);
30
String format = String.format("%02d:%02d",
TimeUnit.MILLISECONDS.toMinutes(millis) %
TimeUnit.HOURS.toMinutes(1),
TimeUnit.MILLISECONDS.toSeconds(millis) %
TimeUnit.MINUTES.toSeconds(1));
return format;
}
}

MyMediaPlayer.java

package com.example.musicplayer;

import android.media.MediaPlayer;

public class MyMediaPlayer {


static MediaPlayer instance;

public static MediaPlayer getInstance(){


if(instance == null){
instance = new MediaPlayer();
}
return instance;
}

public static int currentIndex = -1;


}

activity_main.xml

<?xml version="1.0" encoding="UTF-8"?>


<RelativeLayout tools:context=".MainActivity"
android:layout_height="match_parent" android:layout_width="match_parent"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"><TextView
android:layout_height="wrap_content" android:layout_width="wrap_content"
tools:ignore="HardcodedText" android:textStyle="bold" android:textSize="20sp"
android:textColor="@color/black" android:text="@string/songs"
android:padding="10dp" android:layout_centerHorizontal="true"
android:id="@+id/songs_text"/><TextView
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:text="@string/no_songs_found" android:id="@+id/no_songs_text"
android:visibility="gone"
31
android:layout_centerInParent="true"/><androidx.recyclerview.widget.RecyclerVi
ew android:layout_height="wrap_content" android:layout_width="match_parent"
android:id="@+id/recycler_view" android:layout_marginTop="14dp"
android:layout_below="@id/songs_text"/></RelativeLayout>

Activity_music_player.xml

<?xml version="1.0" encoding="UTF-8"?>


<RelativeLayout tools:context=".MusicPlayerActivity"
android:background="#F69402" android:layout_height="match_parent"
android:layout_width="match_parent"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"><TextView
android:layout_height="wrap_content" android:layout_width="match_parent"
android:padding="20dp" android:layout_margin="20dp" android:textSize="20dp"
android:textColor="@color/black" android:ellipsize="marquee"
android:singleLine="true" android:fontFamily="sans-serif-black"
android:text="Title of the song" android:id="@+id/song_title"/><ImageView
android:layout_height="240dp" android:layout_width="240dp"
android:padding="20dp" android:id="@+id/music_icon_big"
android:src="@drawable/music_icon_big" android:layout_above="@id/controls"
android:layout_centerHorizontal="true"/><RelativeLayout
android:layout_height="wrap_content" android:layout_width="match_parent"
android:padding="40dp" android:id="@+id/controls"
android:layout_alignParentBottom="true"><SeekBar
android:layout_height="wrap_content" android:layout_width="match_parent"
android:id="@+id/seek_bar" android:backgroundTint="@color/white"
android:layout_marginBottom="10dp" android:layout_marginEnd="10dp"
android:layout_marginTop="10dp"
android:layout_marginStart="10dp"/><TextView android:layout_height="0dp"
android:layout_width="237dp" android:textColor="@color/white"
android:text="0:00" android:id="@+id/current_time"
android:layout_marginBottom="20dp" android:layout_marginEnd="20dp"
android:layout_marginTop="-11dp" android:layout_marginStart="-63dp"
android:layout_alignParentStart="true"
android:layout_below="@id/seek_bar"/><TextView
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_margin="20dp" android:textColor="@color/white"
android:text="0:00" android:id="@+id/total_time"
android:layout_below="@id/seek_bar"
32
android:layout_alignParentEnd="true"/><RelativeLayout
android:layout_height="wrap_content" android:layout_width="match_parent"
android:padding="20dp" android:layout_below="@id/total_time"><ImageView
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:id="@+id/previous"
android:src="@drawable/ic_baseline_skip_previous_24"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"/><ImageView
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:id="@+id/next" android:src="@drawable/ic_baseline_skip_next_24"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"/><ImageView
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:id="@+id/pause_play"
android:src="@drawable/ic_baseline_pause_circle_outline_24"
android:layout_centerInParent="true"/></RelativeLayout></RelativeLayout></
RelativeLayout>

Recycler_item.xml

<?xml version="1.0" encoding="UTF-8"?>

-<RelativeLayout xmlns:tools="http://schemas.android.com/tools"
android:paddingBottom="10dp" android:paddingTop="10dp"
android:layout_marginRight="5dp" android:layout_marginLeft="5dp"
android:layout_marginTop="5dp" android:background="#F6B8B8"
android:layout_height="wrap_content" android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">

<ImageView android:layout_height="36dp" android:layout_width="36dp"


android:src="@drawable/music_icon" android:layout_centerVertical="true"
android:id="@+id/icon_view"/>

<TextView android:layout_height="wrap_content"
android:layout_width="match_parent" android:id="@+id/music_title_text"
tools:text="Music" android:textSize="20dp" android:textColor="@color/black"
android:padding="10dp" android:maxLines="1" android:fontFamily="sans-serif-
black" android:ellipsize="end" android:layout_toEndOf="@id/icon_view"
android:layout_marginStart="0dp"/>

</RelativeLayout>

ic_baseline_pause_circle_outline_24.xml
33
<?xml version="1.0" encoding="UTF-8"?>

-<RelativeLayout xmlns:tools="http://schemas.android.com/tools"
android:paddingBottom="10dp" android:paddingTop="10dp"
android:layout_marginRight="5dp" android:layout_marginLeft="5dp"
android:layout_marginTop="5dp" android:background="#F6B8B8"
android:layout_height="wrap_content" android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">

<ImageView android:layout_height="36dp" android:layout_width="36dp"


android:src="@drawable/music_icon" android:layout_centerVertical="true"
android:id="@+id/icon_view"/>

<TextView android:layout_height="wrap_content"
android:layout_width="match_parent" android:id="@+id/music_title_text"
tools:text="Music" android:textSize="20dp" android:textColor="@color/black"
android:padding="10dp" android:maxLines="1" android:fontFamily="sans-serif-
black" android:ellipsize="end" android:layout_toEndOf="@id/icon_view"
android:layout_marginStart="0dp"/>

</RelativeLayout>

ic_baseline_play_circle_outline_24.xml

<?xml version="1.0"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="64dp" android:viewportWidth="24" android:viewportHeight="24"
android:tint="#000000" android:height="64dp"><path
android:pathData="M10,16.5l6,-4.5 -6,-4.5v9zM12,2C6.48,2 2,6.48 2,12s4.48,10
10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8
8,3.59 8,8 -3.59,8 -8,8z" android:fillColor="@android:color/white"/></vector>

ic_baseline_skip_next_24.xml

<?xml version="1.0"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="64dp" android:viewportWidth="24" android:viewportHeight="24"
android:tint="#000000" android:height="64dp"><path
android:pathData="M6,18l8.5,-6L6,6v12zM16,6v12h2V6h-2z"
android:fillColor="@android:color/white"/></vector>

34
ic_baseline_skip_previous_24.xml

<?xml version="1.0"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="64dp" android:viewportWidth="24" android:viewportHeight="24"
android:tint="#000000" android:height="64dp"><path
android:pathData="M6,6h2v12L6,18zM9.5,12l8.5,6L18,6z"
android:fillColor="@android:color/white"/></vector>

ic_launcher.xml

<?xml version="1.0" encoding="UTF-8"?>


<adaptive-icon
xmlns:android="http://schemas.android.com/apk/res/android"><background
android:drawable="@drawable/ic_launcher_background"/><foreground
android:drawable="@drawable/ic_launcher_foreground"/></adaptive-icon>

ic_launcher_round.xml

<?xml version="1.0" encoding="UTF-8"?>

-<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">

<background android:drawable="@drawable/ic_launcher_background"/>

<foreground android:drawable="@drawable/ic_launcher_foreground"/>

</adaptive-icon>

Colors.xml

<?xml version="1.0" encoding="UTF-8"?>


<resources><color name="purple_200">#FFBB86FC</color><color
name="purple_500">#FF6200EE</color><color
name="purple_700">#FF3700B3</color><color
name="teal_200">#FF03DAC5</color><color
name="teal_700">#FF018786</color><color
name="black">#FF000000</color><color
name="white">#FFFFFFFF</color></resources>

35
Strings.xml

<?xml version="1.0"?>

-<resources>

<string translatable="false" name="app_name">MusicPlayer</string>

<string translatable="false" name="songs">SONGS</string>

<string translatable="false" name="no_songs_found">NO SONGS


FOUND</string>

</resources>

themes.xml

<?xml version="1.0"?>

-<resources xmlns:tools="http://schemas.android.com/tools">

<!-- Base application theme. -->

-<style parent="Theme.MaterialComponents.DayNight.NoActionBar"
name="Theme.MusicPlayer">

<!-- Primary brand color. -->

<item name="colorPrimary">@color/purple_500</item>

<item name="colorPrimaryVariant">@color/purple_700</item>

<item name="colorOnPrimary">@color/white</item>

<!-- Secondary brand color. -->

<item name="colorSecondary">@color/teal_200</item>

36
<item name="colorSecondaryVariant">@color/teal_700</item>

<item name="colorOnSecondary">@color/black</item>

<!-- Status bar color. -->

<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>

<!-- Customize your theme here. -->

</style>

</resources>

Themes.xml

<?xml version="1.0"?>
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style parent="Theme.MaterialComponents.DayNight.DarkActionBar"
name="Theme.MusicPlayer">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_200</item><item
name="colorPrimaryVariant">@color/purple_700</item><item
name="colorOnPrimary">@color/black</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item><item
name="colorSecondaryVariant">@color/teal_200</item><item
name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style></resources>

backup_rules.xml

<?xml version="1.0" encoding="UTF-8"?>


<!-- Sample backup rules file; uncomment and customize as necessary. See
https://developer.android.com/guide/topics/data/autobackup for details. Note: This
file is ignored for devices older that API 31 See
https://developer.android.com/about/versions/12/backup-restore -->
37
<full-backup-content>
<!-- <include domain="sharedpref" path="."/> <exclude domain="sharedpref"
path="device.xml"/> -->
</full-backup-content>

<?xml version="1.0" encoding="UTF-8"?>

<!--Sample data extraction rules file; uncomment and customize as necessary.See


https://developer.android.com/about/versions/12/backup-restore#xml-changesfor
details. -->

-<data-extraction-rules>

-<cloud-backup>

<!-- TODO: Use <include> and <exclude> to control what is backed


up.<include .../><exclude .../> -->

</cloud-backup>

<!--<device-transfer><include .../><exclude .../></device-transfer> -->

</data-extraction-rules>

ExampleUnitTest.java

package com.example.musicplayer;

import org.junit.Test;

import static org.junit.Assert.*;

/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
38
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}

MyMediaPlayerTest.java

package com.example.musicplayer;

import junit.framework.TestCase;

public class MyMediaPlayerTest extends TestCase {


}

ExampleInstrumentedTest.java

package com.example.musicplayer;

import android.content.Context;

import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext =
InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.example.musicplayer", appContext.getPackageName());
39
}
}

3.SCREENSHOTS

40
Fig: 3.1 Song List

41
Fig: 3.2-Player List

42
Fig: 3.3-Medai Player

43
44
45
4.Conclusion

We have implemented the ONLINE HEALTHCARE ADVISOR using Open


source Software HTML using the PHP platform. The proposed system in which we took the idea
that the project was to implement a computer-based Healthcare Information System. This system
helps the users to identify certain diseases by answering certain questions asked by the system.
Based on the diagnosis received the user will be getting some suggestions of medicines that are
available at the local chemist without prescription with advice to visit the doctor.Finally, we
achieve the patient without consulting the doctor and take some medical advice in the
application. And the application is used by the patient to get some medical advice without
consulting the doctor. And it is used for emergency purposes.

46

You might also like