Java Reference
In-Depth Information
else
{
initMediaPlayer();
if (mediaType.startsWith("audio")) {
configViewSound();
} else if (mediaType.startsWith("video")) {
configViewVideo();
}
player.start();
}
display.setCurrent(viewerDisplayable);
} catch (Exception e) {
showException(e);
}
}
private void showException(Exception e) {
Alert a = new Alert("Exception", e.toString(), null, null);
a.setTimeout(Alert.FOREVER);
display.setCurrent(a, viewerDisplayable);
}
}
The MIDlet source opens with a few import directives, because it relies on the MIDP
APIs as well as the MMAPI and the SVGAPI. The MIDlet follows the basic organization of
all MIDlets in the topic, eschewing initialization in the constructor in favor of an explicit
init method that the startApp method invokes when the AMS launches the MIDlet. The
following methods are responsible for MIDlet behavior:
startApp , pauseApp , and destroyApp : These methods together manage the life cycle
of the MIDlet. Starting the MIDlet shows a list of media to play, while pausing or
quitting the MIDlet stops any pending media playback.
init : As previously mentioned, init creates the initial List instance showing the
choices for media playback. It also dumps a list of supported media types to the
system console using the showSupportedMedia method.
commandAction : This method processes user selections from the initial List screen
and permits you to capture a video frame during video playback.
run : The application uses a separate thread (which I'll call the player thread ) for
media playback; this thread executes the run method, which starts media playback
and waits for a request from the user to capture media.
 
Search WWH ::




Custom Search