You are on page 1of 29

lOMoARcPSD|26328390

Final Report-MADLab - Mad project

Engineering (Maharaja Surajmal Institute of Technology)

Studocu is not sponsored or endorsed by any college or university


Downloaded by Likith Pal (likipal460@gmail.com)
lOMoARcPSD|26328390

VISVESVARAYA TECHNOLOGICAL
UNIVERSITY
―Jnana Sangama‖, Belgaum, Karnataka 3 590018

A MINI PROJECT REPORT


ON

<MEDIA PLAYER=
Submitted in partial fulfillment of requirements for the
Mobile Application Development Laboratory with Mini Project
Bachelor of Engineering
In
Information Science & Engineering

Submitted by

RAHUL K [4MH19IS075]

NISCHITH GOWDA K S [4MH18IS061]

Under the Guidance


of
Prof. RAMYA S
Asst. Professor
Dept. of IS&E
MIT, Mysore.

2021 – 2022
DEPARTMENT OF INFORMATION SCIENCE & ENGINEERING
MAHARAJA INSTITUTE OF TECHNOLOGY MYSORE
BELAVADI, S.R. PATNA (T), MANDYA (D) – 571477.

I
Downloaded by Likith Pal (likipal460@gmail.com)
lOMoARcPSD|26328390

DEPARTMENT OF INFORMATION SCIENCE &ENGINEERING


MAHARAJA INSTITUTE OF TECHNOLOGY MYSORE
MANDYA – 571477.

CERTIFICATE

Certified that the project work entitled ―MEDIA PLAYER has been
successfully carried out by RAHUL K [4MH19IS075] & NISCHITH GOWDA K S
[4MH18IS061] bonafide students of Maharaja Institute of Technology in partial fulfilment
of the requirements of MOBILE APPLICATION AND DEVELOPMENT
LABORATORY
WITH MINI PROJECT in Information Science and Engineering of Visvesvaraya
Technological University, Belgaum during the academic year 2021-2022. It is certified that
all corrections/suggestions indicated for the Internal Assessment have been incorporated in the
report deposited in the department library. The project report has been approved as it satisfies
the academic requirements with respect to the project work prescribed for Bachelor of
Engineering Degree.

Signature of Guide Signature of HOD


(Prof. Ramya S) (Dr. Sharath Kumar Y H)
Asst. Professor, Dept. of IS&E Professor & Head, Dept. of IS&E
MIT Mysore. MIT Mysore.

Name of the Examiners External Viva Signature with date

1.

2.

II
Downloaded by Likith Pal (likipal460@gmail.com)
lOMoARcPSD|26328390

ACKNOWLEDGEMENT

We sincerely owe our gratitude to all the persons who helped and guided us in completing this
mini project work.

We are thankful to Dr. B G Naresh Kumar, Principal, Maharaja Institute of Technology


Mysore, for having supported us in our academic endeavour.

We are extremely thankful to Dr. Sharath Kumar Y H, Professor & Head, Department of
Information Science and Engineering, for his valuable support and his timely inquiries into
the progress of the work.

We are greatly indebted to our guide Prof. Ramya S, Asst. Professor, Department of
Information Science and Engineering, for the consistent co-operation and support.

We are obliged to all teaching and non-teaching staff members of Department of


Information Science and Engineering, for the valuable information provided by them in their
respective field’s.

We are grateful for their co-operation during the period of our mini project.

RAHUL K [4MH19IS075]

NISCHITH GOWDA K S [4MH18IS061]

III
Downloaded by Likith Pal (likipal460@gmail.com)
lOMoARcPSD|26328390

ABSTRACT

Android purposes play a principal position nowadays. Applications in most cases make
ease of the work. The designed software majorly which supplies interesting know-how and
what activities. Moreover, users will doubtless be able to govern their celebration participation,
corresponding to reserving their seats in events, registering to the occasion on this android
utility by means of the cell, and plenty of others.
More importantly, the major talent of this software is it can be used for local event
administration similar to pursuits in schools, colleges and so on and will also be used for public
occasion administration such as music live shows, academic workshops and many other.
Also, it consists of alarm mechanism for the scheduled meetings in order to notify
people about the meeting scheduled. It can also be used for scheduling personal event, company
meetings etc. It is a very user-friendly utility that serves the entire performance of event
decision and registration.

IV
Downloaded by Likith Pal (likipal460@gmail.com)
lOMoARcPSD|26328390

Media Player 2021-22

TABLE OF CONTENTS

Sl No. Title Page


1. Introduction 1-3

1.1 Overview 1

1.2 Problem statement 1

1.3 The solution 1-2

1.4 Proposed System 3

2. Software Requirement Specification 3-5

2.1 Functional 3
2.2 Nonfunctional requirements 3
2.3 Software and Hardware Specification 3--5

3. Implementation 6-18

3.1 Introduction to Mobile Application development and its architecture 6-7

3.2 Asynchronous Task 8

3.3 SQLite Database 8-9

3.4 Buttons 9

3.5 Architecture of android 9-11

3.6 The Clipboard architecture 11-12

3.7 Android clipboard framework 13

3.8 Code Implementation

3.8.1 Main_Activity.Xml 14-16

3.8.2 MainActivity.Java 16-21

4. Snapshots 22

4.1 Before playing music 22

4.2 After playing music 22

Conclusion 23

Reference 24

Dept. of IS Downloaded by Likith Pal (likipal460@gmail.com)


Page 1
lOMoARcPSD|26328390

Media Player 2021-22

Chapter 1

Introduction

1.1 Overview
The Android multimedia framework includes support for playing variety of common
media types, so that you can easily integrate audio, video and images into your applications.
You can play audio or video from media files stored in your application's resources (raw
resources), from standalone files in the file system, or from a data stream arriving over a
network connection, all using Media Player APIs.
This document shows you how to use Media Player to write a media-playing application
that interacts with the user and the system in order to obtain good performance and a pleasant
user experience. Alternatively, you might want to use Exo player, which is a customizable
open-source library that supports high-performance features not available in Media Player

1.2 Problem statement

In Android, there are some problems that it is difficult to assure a security by application
implementation due to a specification of Android OS or a function which Android OS provides.
By being abused by the malicious third party or used by users carelessly, these functions are
always holding risks that may lead to security problems like information leakage. In this chapter,
by indicating risk mitigation plans those developers can take against these functions, some topics
that needs calling attentions, are picked up as articles.

Develop an a6pplication that makes use of the clipboard framework for copying and
pasting of the text.

1.3 The solution

The solution of simple media player is as follows

 Simple User interface.

 Complexity removed.

Dept. of IS Downloaded by Likith Pal (likipal460@gmail.com)


Page 2
lOMoARcPSD|26328390

Media Player 2021-22

 Bugs are minimized.

 Buffering minimized

1.4 Proposed System

To create a simple clipboard framework android application that allows simple copy paste
of text consisting of Text. The clipboard is a buffer that some operating systems provide for
short- term storage and transfer within and between application programs. The clipboard is
usually temporary and unnamed, and its contents reside in the computer's RAM.

The clipboard provides an application programming interface by which programs can


specify cut, copy and paste operations. It is left to the program to define methods for the user to
command these operations, which may include key bindings and menu selections. When an
element is copied or cut, the clipboard must store enough information to enable a sensible
result no matterwhere the element is pasted. Application programs may extend the clipboard
functions that the operating system provides. A clipboard manager may give the user additional
control over the clipboard. Specific clipboard semantics vary among operating systems, can
also vary between versions of the same system, and can sometimes be changed by programs
and by user preferences.

Dept. of IS Downloaded by Likith Pal (likipal460@gmail.com)


Page 3
lOMoARcPSD|26328390

Media Player 2021-22

Chapter 2

Software Requirement Specification

2.1 Functional Requirements


• Button

• Edit text

• Textview

2.2 Non functional requirements


 Availability 3 requirements for app continuous running, for example, 24/7, minimum idle
time, etc.
 Reliability 3 app behavior in case of alarm status, for example, automatic restart and
operation recovery. 
 Scalability 3 ways to expand the system and avoid adversely affected performance.

 Performance 3 how many simultaneous users or transactions the system is to service and its
response time.
 Security 3 app operation and use of safety requirements related to access control, private
data processing, and external attack risk reduction.
 Usability 3 ease of use and user-friendly interface, that allow users to seamlessly interact
with the product.
 Extensibility 3 requirements for app extensibility in case there is a need to add new
functional requirements.

2.3 Software and Hardware Specification

Software Requirement

 64-bit Microsoft® Windows® 8/10.


 x86_64 CPU architecture; 2nd generation Intel Core or newer, or AMD CPU with support
for a Windows Hypervisor.

Dept. of IS Downloaded by Likith Pal (likipal460@gmail.com)


Page 4
lOMoARcPSD|26328390

Media Player 2021-22

 8 GB RAM or more.

 8 GB of available disk space minimum (IDE + Android SDK + Android Emulator)

• 1280 x 800 minimum screen resolution.

Hardware Specification
 Processor- Intel Atom® Processor Z2520 1.2 GHz, or faster processor

 Storage- Between 850 MB and 1.2 GB, depending on the language version

 RAM- Minimum of 512 MB, 4 GB is recommended

Software specification

Android Studio

Android Studio is the official integrated development environment (IDE) for


Google's Android operating system, built on JetBrains' IntelliJ IDEA software and designed
specifically for Android development.[8] It is available for download on Windows, macOS
and Linux based operating systems or as a subscription-based service in 2020. It is a replacement
for the Eclipse Android Development Tools (E-ADT) as the primary IDE for native Android
application development.
Android Studio was announced on May 16, 2013 at the Google I/O conference. It was in
early access preview stage starting from version 0.1 in May 2013, then entered beta stage starting
from version 0.8 which was released in June 2014. The first stable build was released in
December 2014, starting from version 1.0.
On May 7, 2019, Kotlin replaced Java as Google's preferred language for Android app
development.

Oracle JVM

The Oracle JVM is a standard, Java-compatible environment that runs any pure Java
application. It is compatible with the standard JLS and the JVM specifications. It supports the
standard Java binary format and the standard Java APIs. In addition, Oracle Database adheres to
standard Java language semantics, including dynamic class loading at run time.

Dept. of IS Downloaded by Likith Pal (likipal460@gmail.com)


Page 5
lOMoARcPSD|26328390

Media Player 2021-22

Java in Oracle Database introduces the following terms:

1) Session

A session in Oracle Database Java environment is identical to the standard Oracle Database
usage. A session is typically, although not necessarily, bounded by the time a single user
connects to the server. As a user who calls a Java code, you must establish a session in the
server.

2) Call

When a user causes a Java code to run within a session, it is termed as a call. A call can be
started in the following different ways:

 A SQL client program runs a Java stored procedure.

 A trigger runs a Java stored procedure.

 A PL/SQL program calls a Java code.

 In all the cases defined, a call begins, some combination of Java, SQL, or PL/SQL code
is run to completion, and the call ends.

Dept. of IS Downloaded by Likith Pal (likipal460@gmail.com)


Page 6
lOMoARcPSD|26328390

Media Player 2021-22

Chapter 3

Implementation

3.1 Introduction to Mobile Application development and its


architecture

Mobile application development is the process to making software for smartphones and
digitalassistants, most commonly for Android and IOS. The software can be preinstalled on the
device, downloaded from a mobile app store or accessed through a mobile web browser. The
programming and markup languages used for this kind of software development include Java,
Swift, C# and HTML5.
Mobile app development is rapidly growing. From retail, telecommunications and e-
commerceto insurance, healthcare and government, organizations across industries must meet
user expectations for real-time, convenient ways to conduct transactions and access
information.
Today, mobile devices4and the mobile applications that unlock their value4are the
most popular way for people and businesses to connect to the internet. To stay relevant,
responsive and successful, organizations need to develop the mobile applications that their
customers, partners and employees demand.
Yet mobile application development might seem daunting. Once you’ve selected the
OS platform or platforms, you need to overcome the limitations of mobile devices and
usher your app all the way past the potential hurdles of distribution. Fortunately, by
following afew basic guidelines and best practices, you can streamline your application
developmentjourney. learn more about the specifics of mobile application development
on either platform, read our articles on IOS app development and Android app
development.
To explore mobile application development, see IBM's simple tutorial on building a voice-
enabled Android-based chatbot.

Dept. of IS Downloaded by Likith Pal (likipal460@gmail.com)


Page 7
lOMoARcPSD|26328390

Media Player 2021-22

XML
Extensible Markup Language (XML) is a markup language that defines a set of rules for
encoding documents in a format that is both human-readable and machine-readable. The World

Wide Web Consortium's XML 1.0 Specification of 1998 and several other related specifications
all of them free open standards define XML.

The design goals of XML emphasize simplicity, generality, and usability across the
Internet. It is a textual data format with strong support via Unicode for different human
languages. Althoughthe design of XML focuses on documents, the language is widely used for
the representation ofarbitrary data structures such as those used in web services.
Several schema systems exist to aid in the definition of XML-based languages, while
programmers have developed many application programming interfaces (APIs) to aid the
processing of XML data.

JAVA
Java is a high-level, class-based, object-oriented programming language that is designedto
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 withoutthe 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. As of 2019, Java was one of the most popular programming
languages in use according to GitHub, particularly for client-server web applications, with a
reported 9 million developers.
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 GPL-2.0-only 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 develpoers and is the default JVM for almost all Linux
distribution

Dept. of IS Downloaded by Likith Pal (likipal460@gmail.com)


Page 8
lOMoARcPSD|26328390

Media Player 2021-22

3.2 Asynchronous Task

Use the AsyncTask class to implement an asynchronous, long-running task on a worker


thread.(A worker thread is any thread which is not the main or UI thread.) AsyncTask allows
you to perform background operations and publish results on the UI thread without
manipulating threads or handlers.
When AsyncTask is executed, it goes through four steps:
1. onPreExecute() is invoked on the UI thread before the task is executed. This step is
normally used to set up the task, for instance by showing a progress bar in the UI.
2. doInBackground(Params...) is invoked on the background thread immediately after
onPreExecute() finishes. This step performs a background computation, returns a result,
and passes the result to onPostExecute(). The doInBackground() method can also call
publishProgress(Progress...) to publish one or more units of progress.
2. onProgressUpdate(Progress...) runs on the UI thread after publishProgress(Progress...) is
invoked. Use onProgressUpdate() to report any form of progress to the UI thread while the
background computation is executing. For instance, you can use it to pass the data to
animate a progress bar or show logs in a text field.
3. onPostExecute(Result) runs on the UI thread after the background computation has
finished.

3.3 SQLiteDatabase

This chapter discusses the Android framework's SQLiteDatabase and SQLiteOpenHelper


classes. It is not an introduction to SQLite or SQL databases.The chapter assumes that you are

familiar with SQL databases in general, and basic SQL query building. Check out the SQL
Primer chapter if you need a refresher.
Of the many storage options discussed, using a SQLite database is one of the most
versatile,and straightforward to implement.
 An SQLite database is a good storage solution when you have structured data that you
need to store persistently and access, search, and change frequently.
 You can use the database as the primary storage for user or app data, or you can use it
cache and make available data fetched from the cloud.
 If you can represent your data as rows and columns, consider a SQLite database.

 Content providers, which will be introduced in a later chapter, work excellently

Dept. of IS Downloaded by Likith Pal (likipal460@gmail.com)


Page 9
lOMoARcPSD|26328390

Media Player 2021-22

SQLite databases.

When you use an SQLite database, represented as an SQLiteDatabase object, all

interactions with the database are through an instance of the SQLiteOpenHelper class which

executes your requests and manages your database for you. Your app should only interact withthe

SQLiteOpenHelper, which will be described below.

3.4 Buttons

A button consists of text or an icon (or both text and an icon) that communicates what
actionoccurs when the user touches it.
epending on whether you want a button with text, an icon, or both, you can create the button in
your layout in three ways:
 With text, using the Button class:

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_text"
... />

3.5 Architecture of android

Dept. of IS Downloaded by Likith Pal (likipal460@gmail.com)


Page 10
lOMoARcPSD|26328390

Media Player 2021-22

1) Linux kernel
It is the heart of android architecture that exists at the root of android architecture. Linux
kernel is responsible for device drivers, power management, memory management, device
managementand resource access.

2) Native Libraries
On the top of linux kernel, their are Native libraries such as WebKit, OpenGL, FreeType,
SQLite,Media, C runtime library (libc) etc.
The WebKit library is responsible for browser support, SQLite is for database, FreeType for
fontsupport, Media for playing and recording audio and video formats.

3) Android Runtime
In android runtime, there are core libraries and DVM (Dalvik Virtual Machine) which is
responsible to run android application. DVM is like JVM but it is optimized for mobile devices.
It consumes less memory and provides fast performance.

4) Android Framework
On the top of Native libraries and android runtime, there is android framework. Android
framework includes Android API's such as UI (User Interface), telephony, resources, locations,
Content Providers (data) and package managers. It provides a lot of classes and interfaces for
android application development.

5) Applications
On the top of android framework, there are applications. All applications such as home,
contact, settings, games, browsers are using android framework that uses android runtime and
libraries. Android runtime and native libraries are using linux kerne

6) Linux kernel
It is the heart of android architecture that exists at the root of android architecture. Linux
kernel is responsible for device drivers, power management, memory management, device
managementand resource access.

7) Native Libraries
On the top of linux kernel, their are Native libraries such as WebKit, OpenGL, FreeType,

Dept. of IS Downloaded by Likith Pal (likipal460@gmail.com)


Page 11
lOMoARcPSD|26328390

Media Player 2021-22

SQLite,Media, C runtime library (libc) etc.


The WebKit library is responsible for browser support, SQLite is for database, FreeType for
fontsupport, Media for playing and recording audio and video formats.

8) Android Runtime
In android runtime, there are core libraries and DVM (Dalvik Virtual Machine) which is
responsible to run android application. DVM is like JVM but it is optimized for mobile devices.
It consumes less memory and provides fast performance.

9) Android Framework
On the top of Native libraries and android runtime, there is android framework. Android
framework includes Android API's such as UI (User Interface), telephony, resources, locations,
Content Providers (data) and package managers. It provides a lot of classes and interfaces for
android application development.

10) Applications
On the top of android framework, there are applications. All applications such as home,
contact, settings, games, browsers are using android framework that uses android runtime and
libraries. Android runtime and native libraries are using linux kernel.

3.6 The Clipboard Architecture

When you use the clipboard architecture, you put data into a clip object, and then put the
clip object on the system-wide clipboard. The clip object can take one of three forms:

Dept. of IS Downloaded by Likith Pal (likipal460@gmail.com)


Page 12
lOMoARcPSD|26328390

Media Player 2021-22

 Text

A text string. You put the string directly into the clip object, which you then put onto the
clipboard. To paste the string, you get the clip object from the clipboard and copy the string to
into your application's storage.

 URI

A Uri object representing any form of URI. This is primarily for copying complex data
from a content provider. To copy data, you put a Uri object into a clip object and put the clip
object onto the clipboard. To paste the data, you get the clip object, get the Uri object, resolve it
to a data source such as a content provider, and copy the data from the source into your
application's storage.

 Intent

An Intent. This supports copying application shortcuts. To copy data, you create an Intent,
put it into a clip object, and put the clip object onto the clipboard. To paste the data, you get the
clip object and then copy the Intent object into your application's memory area.

The clipboard holds only one clip object at a time. When an application puts a clip object on the
clipboard, the previous clip object disappears.

If you want to allow users to paste data into your application, you don't have to handle all
types of data. You can examine the data on the clipboard before you give users the option to paste
it. Besides having a certain data form, the clip object also contains metadata that tells you what
MIME type or types are available. This metadata helps you decide if your application can do
something useful with the clipboard data. For example, if you have an application that primarily
handles text, you may want to ignore clip objects that contain a URI or Intent.

You may also want to allow users to paste text regardless of the form of data on the
clipboard. To do this, you can force the clipboard data into a text representation, and then paste this
text

Dept. of IS Downloaded by Likith Pal (likipal460@gmail.com)


Page 13
lOMoARcPSD|26328390

Media Player 2021-22

3.7 Android Clipboard Framework

Clipboard framework consists of :

 Clipboard Manager: Clipboard Manager class represents System Clipboard.


 ClipData: An object ClipData is created to hold the Clip description and Data Item itself.
 ClipData.Item: It is in the ClipData object. It holds the data as URI, Text or Intent data.
 ClipDescription: ClipDescription object is used to hold the metadata about the Clip.
 ClipData Methods: ClipData methods are those methods that help in creating and operating
on Clipdata objects at ease.

Dept. of IS Downloaded by Likith Pal (likipal460@gmail.com)


Page 14
lOMoARcPSD|26328390

Media Player 2021-22

3.8 Code Implementation

3.8.1 Main_Activity.Xml

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


<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
android:background="@color/fan"
tools:context=".MainActivity">

<ImageView
android:layout_width="match_parent"
android:layout_height="483dp"
android:src="@drawable/ic_round_log" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="12dp">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/player_position"
android:text="00:00"
android:textStyle="bold"
android:textColor="@android:color/white"/>

<SeekBar
android:layout_width="0dp"
Dept. of IS Downloaded by Likith Pal (likipal460@gmail.com)
Page 15
lOMoARcPSD|26328390

Media Player 2021-22

android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/seek_bar"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/player_duration"
android:text="00:00"
android:textStyle="bold"
android:textColor="@android:color/white"/>

</LinearLayout>

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="8dp">

<ImageView
android:id="@+id/bt_rew"
android:layout_width="60dp"
android:layout_height="match_parent"
android:src="@drawable/ic_fast_rewind" />

<ImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:id="@+id/bt_play"
android:src="@drawable/ic_play"/>

<ImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:id="@+id/bt_pause"

Dept. of IS Downloaded by Likith Pal (likipal460@gmail.com)


Page 16
lOMoARcPSD|26328390

Media Player 2021-22

android:visibility="gone"
android:src="@drawable/ic_pause"/>
<ImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:id="@+id/bt_ff"
android:src="@drawable/ic_fast_forward"/>
</LinearLayout>

</LinearLayout>
</RelativeLayout>

3.8.2 MainActivity.Java

package com.example.mediaapp;

import androidx.appcompat.app.AppCompatActivity;

import android.annotation.SuppressLint;

import android.media.MediaPlayer;

import android.os.Bundle;

import android.os.Handler;

import android.view.View;

import android.widget.ImageView;

import android.widget.SeekBar;

import android.widget.TextView;

import java.util.concurrent.TimeUnit;

public class MainActivity extends AppCompatActivity {

TextView playerPosition,playerDuration;

SeekBar seekBar;

Dept. of IS Downloaded by Likith Pal (likipal460@gmail.com)


Page 17
lOMoARcPSD|26328390

Media Player 2021-22

ImageView btRew,btPlay,btPause,btFf;

MediaPlayer mediaPlayer;

Handler handler = new Handler();

Runnable runnable;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

playerPosition = findViewById(R.id.player_position);

playerDuration = findViewById(R.id.player_duration);

seekBar = findViewById(R.id.seek_bar);

btRew = findViewById(R.id.bt_rew);

btPlay = findViewById(R.id.bt_play);

btPause = findViewById(R.id.bt_pause);

btFf = findViewById(R.id.bt_ff);

mediaPlayer = MediaPlayer.create(this,R.raw.music);

runnable = new Runnable() {

@Override

public void run() {

seekBar.setProgress(mediaPlayer.getCurrentPosition());

handler.postDelayed(this,500);

};

int duration = mediaPlayer.getDuration();

String sDuration = convertFormat(duration);

Dept. of IS Downloaded by Likith Pal (likipal460@gmail.com)


Page 18
lOMoARcPSD|26328390

Media Player 2021-22

playerDuration.setText(sDuration);

btPlay.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

btPlay.setVisibility(View.GONE);

btPause.setVisibility(View.VISIBLE);

mediaPlayer.start();

seekBar.setMax(mediaPlayer.getDuration());

handler.postDelayed(runnable,0);

});

btPause.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

btPause.setVisibility(View.GONE);

btPlay.setVisibility(View.VISIBLE);

mediaPlayer.pause();

handler.removeCallbacks(runnable);

});

btFf.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

int currentPosition = mediaPlayer.getCurrentPosition();

int duration = mediaPlayer.getDuration();

Dept. of IS Downloaded by Likith Pal (likipal460@gmail.com)


Page 19
lOMoARcPSD|26328390

Media Player 2021-22

if(mediaPlayer.isPlaying() && duration != currentPosition){

currentPosition = currentPosition + 5000;

playerPosition.setText(convertFormat(currentPosition));

mediaPlayer.seekTo(currentPosition);

});

btRew.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

int currentPosition = mediaPlayer.getCurrentPosition();

if(mediaPlayer.isPlaying() && currentPosition > 5000){

currentPosition = currentPosition - 5000;

playerPosition.setText(convertFormat(currentPosition));

mediaPlayer.seekTo(currentPosition);

});

seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

@Override

public void onProgressChanged(SeekBar seekBar, int i, boolean b) {

if(b){

mediaPlayer.seekTo(i);

playerPosition.setText(convertFormat(mediaPlayer.getCurrentPosition()));

Dept. of IS Downloaded by Likith Pal (likipal460@gmail.com)


Page 20
lOMoARcPSD|26328390

Media Player 2021-22

@Override

public void onStartTrackingTouch(SeekBar seekBar) {

@Override

public void onStopTrackingTouch(SeekBar seekBar) {

});

mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {

@Override

public void onCompletion(MediaPlayer mediaPlayer) {

btPause.setVisibility(View.GONE);

btPlay.setVisibility(View.VISIBLE);

mediaPlayer.seekTo(0);

});

@SuppressLint("DefaultLocale")

private String convertFormat(int duration) {

return String.format("%02d:%02d"

, TimeUnit.MILLISECONDS.toMinutes(duration)

,TimeUnit.MILLISECONDS.toSeconds(duration) -

TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(duration)));

Dept. of IS Downloaded by Likith Pal (likipal460@gmail.com)


Page 21
lOMoARcPSD|26328390

Media Player 2021-22

Chapter 4:
SNAPSHOTS

Fig 4.1 :before playing music Fig 4.2 :After Playing music

Dept. of IS Downloaded by Likith Pal (likipal460@gmail.com)


Page 22
lOMoARcPSD|26328390

Media Player 2021-22

Conclusion
Media player Activity is developed for users to Play music . It prove the users sound and
thus provides a better user experience.

By this project we get a neat idea of android studio which offers to build automation,
dependency management, and customisable build configurations. You can configure your
project to include local and hosted libraries, and define build variants that include different
code and resources, and apply different code shrinking and app signing configurations. And
also XML which is flexible way to create information formats and electronically share
structured data via the public internet, as well as via corporate networks

In this project we added a speaking assistance , which tells the user had copied text or
not. In future we are implementing an image copy clipboard to it.

Dept. of IS Downloaded by Likith Pal (likipal460@gmail.com)


Page 23
lOMoARcPSD|26328390

Media Player 2021-22

Reference
 https://www.ibm.com/cloud/learn/mobile-application-development-explained for introduction
 https://google-developer-training.github.io/android-developer-fundamentals-course-
concepts/en/android-developer-fundamentals-course-concepts-en.pdf-Concepts
 https://www.semanticscholar.org/paper/Design-and-implementation-of-music-player-
based-on-Xiang-Chao/be428163863d120116750db6a6922036918b3890-for design and
implementation.
 https://developer.android.com/guide/topics/text/copy-paste - about clipboard framework
and architecture

Dept. of IS Downloaded by Likith Pal (likipal460@gmail.com)


Page 24

You might also like