Paper 4
Paper 4
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
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
2466