Java Reference
In-Depth Information
6.2.1 MusicMate
MusicMate is a cool and trendy name for a light and trendy mobile
application whose main purpose is to be your assistant for music-related
functionality. The first thing to do is to focus on the service you are trying
to enable, as the main task of the application. Its most obvious function
is to play music tracks. Where do those tracks come from? MusicMate
can locate existing music files on your file system and it can help you
purchase new songs or albums from various web services. If one of your
friends likes a song you play to him, MusicMate can beam it to his mobile
(whether he has MusicMate installed or not).
We have defined the main application task well enough for a high-
level example, so let's move to the next stage. CLDC 1.1 and MIDP 2.1
are the environment in which the mobile application lives, so MusicMate
must be a MIDlet, packaged in a JAR file and a signed JAD file. As we
noted in Chapter 3, Java ME on Symbian OS does not impose fixed limits
on the available computing resources, so while we should consider the
download time and keep the JAR to a reasonable size, there is no need
to be strict with packaged resources, such as background images. The
same applies to other computing resources that are redefined by MSA, so
you can focus on good design with reasonable resource utilization rather
than on managing constraints.
Now we need to match the functionalities of MusicMate to the avail-
able MSA Component JSRs. MusicMate must find tracks on your mobile
and provide some persistence mechanism for downloaded songs. We do
that using JSR-75 FileConnection. At the user's request, possibly the first
time it is launched, MusicMate looks in all the subdirectories under all
the roots for existing content:
FileConnection fc = (FileConnection), Connector.READ);
Enumeration filesList = fc.list("*", true);
String fileName;
while (filesList.hasMoreElements()) {
fileName = (String) filesList.nextElement();
fc = (FileConnection) + fileName, Connector.READ);
if (fc.isDirectory()) {
// TODO: search under folder
} else {
// TODO: if is MP3 file, add to list
Now that we have discovered all the tracks, we would like to play
them. Multimedia capabilities are an essential feature of MusicMate and
that obviously means that it uses JSR-135 Mobile Media API to control
audio and multimedia resources and provide support for multimedia
features, such as volume control. The following snippet illustrates playing
a track from the file system:
Search WWH ::

Custom Search