0% found this document useful (0 votes)
5 views4 pages

Paper 4

This paper discusses the design and implementation of a music player application based on the Android operating system. The player features a front-back end architecture, allowing for music playback, user rating, and display of track information. The application was successfully tested, demonstrating stable performance and user-friendly functionality.

Uploaded by

Shruti Salke
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views4 pages

Paper 4

This paper discusses the design and implementation of a music player application based on the Android operating system. The player features a front-back end architecture, allowing for music playback, user rating, and display of track information. The application was successfully tested, demonstrating stable performance and user-friendly functionality.

Uploaded by

Shruti Salke
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

2011 International Conference on Mechatronic Science, Electric Engineering and Computer

August 19-22, 2011, Jilin, China

Design and Implementation of Music Player


based on Android

YU Xiang CHEN Chao QI Jing


School of Communication and Infor School of Communication and Infor School of Communication and Infor
mation Engineering mation Engineering mation Engineering
Chongqing University of Posts and Chongqing University of Posts and Chongqing University of Posts and
Telecommunications Telecommunications Telecommunications
Chongqing, China Chongqing, China Chongqing, China
e-mail: [email protected] e-mail: [email protected] e-mail: [email protected]

Abstract—This paper gives our researching work on how to


design a music player based on Android OS. The music II. ANDROID SOFTWARE PLATFORM
player, which uses the front-back end architecture, is divided
into the part of music playback and the part of player A. System Architecture
interface and music list. Besides the playback functions, the Android is a software stack and is divided into four
music player can also do music rating by user preferences, layers which are applications, application framework,
showing the previous and next music name with libraries and Android runtime, Linux kernel [4] from top to
corresponding information and operating controller into a
down. The applications are written using the Java
panel. The music player runs stably and conveniently during
programming language [4]. The application framework
testing.
provides some APIs for developers, and developers use
Keywords-Android; music player; music rating; these APIs to develop applications. The libraries and
operating control Android runtime provide the support for the run and
functions of applications, the libraries are invoked by
application framework via JNI [5]. Linux kernel, which
I. INTRODUCTION based on version 2.6, acts as a hardware manager and the
With the rapid development of computer and base of upper layers.
communications technology, the mobile phone is more and
more powerful. That is not just a mobile communication B. Application Components
tool in our daily life, a variety of media applications begin Application components are the essential building
to appear on cellphone, such as video calls, multimedia blocks of an Android application, there are four different
player, etc. In order to realize these applications, the types of application components [4].
support of a more powerful development platform is 1) Activity
needed, so the research of smartphone operating system An activity is an interface between application and
and its development has become one of the most active user. An Activity represents a single screen, and each one
areas [1]. is independent of others and communicates with others
In November 2007ˈOHA˄open Handset Alliance˅, through intent [6].
which lead by Google, released a smartphone platform - 2) Service
Android. Android is an open and free platform for mobile A service is a component that runs in the background
terminals which includes operating system, middleware, to perform long-running operations. A service does not
user interface and application software [2]. Android has a provide a user interface. Generally the application which
good development and debugging environment, provides a runs in background will need service, such as music
variety of APIs and supports a variety of common audios/ playback. In this design, the part of playback is achieved
videos decoding. The openness of Android platform can by using service.
not only promote the technical innovation (including the 3) Content Provider
platform itself), but also help to reduce development costs, A content provider is used to share data. Android
and allow manufacturers to customize the characteristic application data is private, and sometimes we need to share
product easily. Therefore, it has a large market potential data between different programs, content provider is to
[3]. provide this function. Through the content provider, other
We designed and implemented a music player based on applications can query or even modify the data (if the
Android in this paper. According to the feature of mobile content provider allows it) [4].
phone, the music player makes full use of screen to show 4) Broadcast Receiver
more information. In addition to the basic functions of A broadcast receiver is used to receive system-wide
playback, the music player can also make music rating and broadcast announcements. It gets a happening of event
display the previous and next music name of current through receiving the broadcast announcements. In this
music. The design of the player also has some significance design, the time’s update of player is achieved by
for developing other applications on Android. broadcast receiver.

978-1-61284-722-1/11/$26.00 ©2011 IEEE 2463


III. DESIGN AND IMPLEMENTATION OF MUSIC PLAYER

A. Software Architecture
The music player adopted front-back end architecture.
The front-end consists of player interface and music list
and was achieved by activity for interacting with user. The
back-end is the implementation of playback which based
on service. The communications between front-end and
back-end are via intent. The architecture is shown in
Figure 1.
B. software modules
The music player consists of some modules which are
tab, player interface, playback, music list, list, file, mp3 Figure 1. the architecture of music player
information, constant value and settings. The block
diagram is shown in Figure 2.
1) Tab module
The tab module is the first module the player runs
when the player is opened, which is used to build two tabs
which are player and music list. The player associated with
player interface and the music list associated with music
list, which not only make full use of screen of mobile
phone, but also switch between player interface and music
list easily. The function of closing player was implemented
in tab module, onCreateOptionsMenu(Menu menu)
function was called to create a menu, and
onOptionsItemSelected (MenuItem item) was called to
complete the menu’s functions. Because of the tab module
is first module when the player runs, in addition to
registering the module in AndroidManifest.xml, the
settings of intent-filter should be done as follows:
<intent-filter>
<action android:name="android.intent.action.MAIN" /> Figure 2. the block diagram of music player
<category
android:name="android.intent.category.LAUNCHER" /> 3) Music list module
</intent-filter> The music list module is used to build music list by
2) Player interface module invoking list module. The music list is clickable, and the
The player interface module provides the player music will play when you click the music name in the list.
interface for user, and the control operations and display The information of the music you clicked is encapsulated
information of player are via it. The player interface in intent and sent to playback module to play the music.
consists of current music name, status, current/total time, 4) Playback module
progress bar, previous, play, pause, stop, next, play mode, The playback module is used to achieve playback and
music rating, previous and next music name. The music related operations, such as play, pause, stop, display the
rating can be one of the features of this design, and its current, previous and next music name and update the
workflow is shown in Figure 3. progress bar. The playback module is the core module
The player interface module needs to interact with which based on service. In this module, we achieved that
other modules. The information is sent to the playback how to translate commands which come from the player
module by invoking startService(intent) after interface module and music list module into operations and
encapsulating it into the intent. The player interface the information which is encapsulated in intent is sent
invokes the constant value module to use the constant through broadcast. The playback module invokes the
value we defined, and invokes the settings module to constant value module to match the commands, and
achieve the function of getting and saving the setting invokes the settings module to get and save the settings
information. In the design of display of current music information.
name, we displayed the music name with the “marquee” Updating the progress bar and time is an important
style to avoid that it can’t display fully due to it is too long. function of player. In this design, TimeTask class was used
The key XML code is shown as follows: to send the time information, and the workflow is shown in
<TextView Figure 4. The original time is used to update the progress
··· bar, and the translated time is used to update the
android:ellipsize="marquee" current/total time. In order not to affect the music player,
android:focusable="true" the separate thread was created to achieve acquisition,
android:marqueeRepeatLimit="marquee_forever"
android:focusableInTouchMode="true"
···/>

2464
Figure 3. the workflow of music rating

conversion and sending work of time. The period of


sending time is 500ms and implemented by invoking
schedule(TimerTask task, long delay, long period) in
Figure 4. the workflow of updating time
Timer class.
In addition to displaying the current music name, the
music player also can display the previous and next music 5) Constant value module
name, the workflow is shown as follows: The constant value module holds a variety of constants
a) if the music list is not empty, encapsulate the defined by ourselves, which represent the various
current music name into intent and go on; else go to g) commands and are used to send and receive the
commands.
b) if there are at least two songs in the music list and 6) Settings module
playing the first one, set the previous music name to Settings module is used to save and get a variety of
“nothing” and encapsulate it into intent, encapsulate the setting values by using SharedPreferences [7].
next music name into intent, and then go to f); else go on SharedPreferences, which provided by Android, is a
c) if there are at least two songs in the music list and mechanism for data access, and data store in the XML file
playing the last one, encapsulate the previous music name as key-value pairs.
into intent, set the next music name to “nothing” and 7) List module
encapsulate it into intent, and then go to f); else go on The list module encapsulates the SimpleAdapter class,
and that could be directly invoked by music list module to
d) if there is only one song in the music list, set the build music list.
previous and next music name to “nothing” and 8) File module
encapsulate these into intent, and then go to f); else go on The file module searches the music files in the SD card
e) encapsulate the previous and next music name and saves the information which can be used to build the
into intent, and go on music list.
f) send the intent via broadcast 9) Mp3 information module
The MP3 information module provides some
g) end operations about attributes of Mp3.

2465
IV. TEST OF MUSIC PLAYER ACKNOWLEDGMENT
We tested the music player after implementing it. The The work was supported by Science and Technology
music player can achieve the functions we designed, such Commission of Chongqing (No.CSTC,2009CA2003) and
as showing the current music name with marquee style, Scientific Research Fund of Municipal Education
playing status, the current/total time, progress bar, fast- Commission of Chongqing in China (Approval No.
forward and fast-backward, etc. the player will close if you KJ080507).
choose the exit on menu. The player storages the current
music automatically when the player is closed, and plays REFERENCES
the music automatically when the player runs next time. [1] Pan Yong-Cai, Liu Wen-chao, Li Xiao.Development and Research
The result is shown in Figure 5. of Music Player Application Based on Android[A].In:2010
International Conference on Communications and Intelligence
V. CONCLUSION Information Security[C].USA: IEEE Computer Society's
Conference Publishing Services,2010:23-25
Android provides a variety of APIs to help develop [2] ZHANG Zheng-zheng,LIN Yao-rong.Development of Android-
application on Android. We completed the design and based Mediaplayer[J].Modern Electronics Technique,2011,34(2):5-
implementation of music player after introducing the 6
Android platform. The music player adopts the front–back [3] LI Yang,FENG Gang,LI Liang,LUO Yong-hua.Development and
end architecture. The tab is adopted in user interface for Research on Multimedia Application Based on Android
[J].Computer and Modernization,2011(4):149-150
switching between the music interface and music list
[4] Google.Android developers[DB/OL].http://developer.android.com
easily. In addition to the common functions of music
player, the music rating and displaying the previous and /guide/basics/what-is-android.html
next music name were achieved. The information display [5] Wikipedia.JNI[DB/OL].http://en.wikipedia.org/wiki/Java_Native_
and main operations were integrated into a panel for easy Interface
use. The methods of design and implementation of the [6] Google.Android developers[DB/OL].http://developer.android.com
player also have the significance for the development of /reference/android/content/Intent.html
Android music player and other applications. [7] Google.Android developers[DB/OL].http://developer.android.com
/guide/topics/data/data-storage.html

Figure 5. the test of music player

2466

You might also like