Design and implementation of music player on android
description
Transcript of Design and implementation of music player on android
Outline
Introduction − What is Android? − Android: How it came to be − Android Features
Android Architecture Anatomy of an Android Application Hello Android Life Cycle of an Android Application Future of Android
DESIGN and implementation of a music player based on Android in this paper. According to the feature of mobile
phone, the music player makes full use of screen to show more information. In addition to the basic functions of
playback, the music player can also make music rating and display the previous and next music name of current
music. The design of the player also has some significance for developing other applications on Android.
ABSTRACT
What is Android?
ANDROID
Open, free software platform for mobile devices with a complete software stack
Operating system Middleware Key mobile applications
Based on Linux operating system Made available as open source via the Apache v2 license
Open Android is...
Allows access to core mobile device functionality through standard API calls − Example
Application can call core functionality such as making calls, sending text messages, using camera...
Developers can create richer and more cohesive experiences for users
Since it's open source, it can be liberally extended as new technologies emerge
All Applications are Equal In Android...
Android does not differentiate between the phone's basic and third party applications − All applications have equal access to the phone's capabilities − Example:
The dialer and home screen can be replaced
Breaking down boundaries Android is...
Information from the web can be combined with data on the phone − Example:
Contacts, calendar or geographic location
Fast and Easy Development Android allows...
SDK (Software development kit) includes − True device emulator and advanced debugging
tools − Useful libraries and tools
Example − Obtain location of the device − Allow devices to communicate with one another
Android Features Application framework
− enable reuse and replacement of components
Dalvik virtual machine − optimized for mobile devices
Integrated browser − based on the open source WebKit engine
Optimized graphics
− powered by a custom 2D graphics library − 3D graphics based on the OpenGL ES 1.0 specification
(hardware acceleration optional)
Android Features SQLite
− For structured data storage
Media support for common audio, video, and still image formats
− MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, GIF
GSM Telephony (hardware dependent)
Bluetooth, EDGE, 3G, and WiFi (hardware dependent)
Camera, GPS, compass, and accelerometer (hardware dependent)
Android Features
Rich development environment which includes
− device emulator − tools for debugging − memory and performance profiling − a plugin for the Eclipse IDE
Android Architecture
Major components of the Android OS
Android Runtime Android Architecture
Main Component: Dalvik Virtual Machine − Optimized for running in an embedded environment (limited
memory, CPU,battery) − Runs .dex files (bytecodes)
.class .jar files
Converted at build
time Optimized! More efficient!
Android Runtime Android Architecture
Core Library − Contains all the collection classes, utilities,
IO, etc.
Applications Android Architecture
Core Applications − Email client − SMS program − Calendar − Maps − Browser − Contacts − etc
All applications are written using the
Java Programming Language
Anatomy of an Android Application
Application Building Blocks Activity Intent Receiver Service Content Provider
Activity Anatomy of an Android Application
Activity UI typically corresponding to one screen Move through screens by starting other activities Example
Email application has 3 major activity
List your mail Chosen individual mail message Compose screen
Intent Receiver Anatomy of an Android Application
Intent Receiver Responds to notifications or status changes Can wake up your process Doesn't run unless triggered by an external event Example
Only run an application when connected to the network
Service Anatomy of an Android Application
Service Faceless task that runs in the background Example
Music player Keeps playing even though you are navigating to other parts
Content Provider Anatomy of an Android Application
Content Provider
Enables applications to share data Example
Any application can access the contacts database
21
Hello Android A Peek at an Android App
22
Hello Android A Peek at an Android App
Application Lifecycle
Every application runs its own process − Benefits: security, protected memory, applications using CPU
intensively won't block other activities
Processes are started and stopped as needed to run an application's components
Processes may be killed to reclaim resources
It's my problem to launch/ kill processes, manage
resources, saving states, etc.
Interesting APIs
Java Code +
XML and Other Resources
+ Manifest File
= Android App
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.
ARCHITECTURE OF MUSIC PLAYER
PLAYER INTERFACE (ACTIVITY)
back end
PLAYBACK (SERVICE)
MUSIC LIST (ACTIVITY)
FRONT END
BACK END
SOFTWARE MODULES
The music player consists of some modules which are tab, player interface, playback, music list, list, file, mp3 information, constant value and settings.
TAB
PLAYER INTERFACE PLAYBACK MUSIC
LIST
LIST
FILE
Mp3 information
CONSTANT VALUE SETTINGS
BLOCK DIAGRAM OF MUSIC PLAYER
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.
2.PLAYER INTERFACE MODULE
The player interface module provides the player interface for user, and the control operations and display information of player are via it. The player interface consists of current music name, status, current/total time, progress bar, previous, play, pause, stop, next, play mode, music rating, previous and next music name.
3.MUSIC LIST MODULE
The music list module is used to build music list by
invoking list module. The music list is clickable, and the
music will play when you click the music name in the list.
The information of the music you clicked is encapsulated
in intent and sent to playback module to play the music.
4.PLAYBACK MODULE
The playback module is used to achieve playback and related operations, such as play, pause, stop, display the current, previous and next music name and update the progress bar. The playback module is the core module which based on service. In this module, we achieved that how to translate commands which come from the player interface module and music list module into operations and the information which is encapsulated in intent is sent through broadcast. The playback module invokes the constant value module to match the commands, and invokes the settings module to get and save the settings information.
THE WORKFLOW OF MUSIC RATING
MUSIC RATING CHANGED
CLICK BY USER
GET THE CURRENT MUSIC NAME
Save the music name and the related music
rating value
DISPLAY THE MUSIC RATING VALUE
END
START
Create the thread of updating time
Define and initialize variable
Player is stop
Get the current time and total
time
Translate the time
Encapsulate time into intent
Send intent via broadcast
WORKFLOW OF UPDATING TIME
5) CONSTANT VALUE MODULE The constant value module holds a variety of constants defined by ourselves, which represent the various commands and are used to send and receive the commands.
6) SETTINGS MODULE Settings module is used to save and get a variety of setting values by using Shared Preferences . Shared Preferences, which provided by Android, is a mechanism for data access, and data store in the XML file as key-value pairs.
7) LIST MODULE The list module encapsulates the Simple Adapter class, and that could be directly invoked by music list module to build music list. 8) FILE MODULE The file module searches the music files in the SD card and saves the information which can be used to build the music list. 9) MP3 INFORMATION MODULE The MP3 information module provides some operations about attributes of Mp3.
Android is a multi-process system, in which each application (and parts of the system) runs in its own process. The ability for anyone to customize the Google Android platform The consumer will benefit from having a wide range of mobile applications to choose from since the monopoly will be broken by Google Android Men will be able to customize a mobile phones using Google Android platform like never before
CONCLUSION