## Chapter 8

## Using the Mobile Media API

The Mobile Media API (MMAPI) provides a standard API for rendering and capturing time-based media, like audio or video. The API was designed to be flexible with respect to the media formats, protocols, and features supported by various devices.

## 8.1 Supported Formats and Protocols

The emulator’s MMAPI implementation supports the following media types:

TABLE 6 – Supported MMAPI media formats
MIME Type | Description
--- | ---
audio/midi | MIDI files
audio/sp-midi | Scalable Polyphony MIDI
audio/x-tone-seq | MIDP 2.0 tone sequence
audio/x-wav | WAV PCM sampled audio
image/gif | GIF 89a (animated GIF)
video/mpeg | MPEG video
video/vnd.sun.rgb565 | Video capture

## 8.2 Using MediaControlSkin

The J2ME Wireless Toolkit comes with an emulator skin, `MediaControlSkin`, that is focused on multimedia playback and control. The skin includes buttons with symbols representing play, stop, volume up and volume down, and other commands. To see the usefulness of `MediaControlSkin`, try it out with the `mmademo` demonstration application.

## 8.3 Media Capture

The J2ME Wireless Toolkit emulator supports audio and video capture. Audio capture is supported by using the capture capabilities of the system upon which the emulator runs.

Video capture is supported by simulating a camera input.

See the `mmademo` example application for details and source code that demonstrates how to capture audio and video.

## 8.4 Well-Behaved MIDlets

MIDlets have a life cycle that is defined in the MIDP specification. MIDlets can be paused by events such as incoming phone calls. A well-behaved MIDlet releases important device resources when it is paused and reallocates or restarts those resources when the MIDlet is resumed. In the MMAPI arena, any `Player`s that are rendering content should be stopped when a MIDlet is paused.

The J2ME Wireless Toolkit will print a message to the console if you pause a MIDlet and it does not stop its running `Player`s. You can test this feature yourself using the `PausingVideoTest` MIDlet in the `mmademo` demonstration application. See Appendix for details.

The warning message is printed once only for each running emulator.

| J2ME Wireless Toolkit User's Guide J2ME Wireless Toolkit 2.2

Copyright © 2004 Sun Microsystems, Inc. All rights reserved. Use is subject to the license terms.