Skip Headers
Oracle® Java Micro Edition Software Development Kit Developer's Guide
Release 3.2 for Eclipse on Windows
  Go To Table Of Contents
Go To Index


16 JSR 135: Mobile Media API Support

JSR 135, the Mobile Media API (MMAPI), provides a standard API for rendering and capturing time-based media, like audio or video. The API is designed to be flexible given the media formats, protocols, and features supported by various devices. See the following topics:

For information on programming with MMAPI, see the following articles:

Mobile Media API Overview:

The J2ME Mobile Media API:

16.1 Media Types

The emulator's MMAPI implementation supports the following media types.

MIME Type Description


Adaptive Multi-Rate Narrow Band


MIDI files


MP3 files


MP4 Audio files


Scalable Polyphony MIDI


MIDP 2.0 tone sequence


WAV PCM sampled audio


GIF 89a (animated GIF)


Third generation mobile broadband with video


MPEG video


MP4 video files


Video capture emulation and Audio-Video Interleaved files

In the previous table, an asterisk (*) indicates a media type that requires corresponding DirectShow filters to be installed on your system. For example, MP3 support might require an MP3 Splitter and an MP3 Decoder (these might be two separate DirectShow filters, or they might be combined in one filter). You can use any appropriate filter, but Java ME SDK 3.2 has only been tested with filters from the K-Lite Mega Codec Pack 4.8.0. If no appropriate DirectShow filters are found on your system, JSR 135 Player creation for the media type might fail.

16.1.1 Media Capture

The Oracle Java ME SDK emulator supports audio and video capture. Audio capture is supported using the capture capabilities of the system upon which the emulator runs.

Video capture is supported by simulating a camera input.

Consult the MobileMediaAPI example application for details and source code that demonstrates how to capture audio and video.

16.2 MMAPI MIDlet Behavior

MIDlets have a lifecycle 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, stop any Players that are rendering content when a MIDlet is paused.

The Oracle Java ME SDK prints a message to the console if you pause a MIDlet and it does not stop its running Players. You can test this feature using the Pausing Audio Test MIDlet.

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

16.3 Ring Tones

MMAPI plays ring tones, as demonstrated in Section 16.5.1, "Simple Tones" and Section 16.5.2, "Simple Player." The ring tone formats mentioned here are in common use. You can download ring tones or create your own.

16.3.1 Download Ring Tones

Ring tone files can be downloaded from many internet sites, including the following:

16.3.2 Ring Tone Formats

This section provides samples of several formats

  • RTTTL, the Ringing Tones text transfer language format, is explained at

  • Nokia Composer

    This is a rendition of Beethoven's 9th symphony in Nokia Composer format:



    16d1,16#g1,16#g1,16#g1, 16g1,16f2,16f2,16f2,4d2

  • Ericsson Composer

    Beethoven's Minuet in G:

    a b + c b + c b + c b + C p + d a B p + c g A

    p f g a g a g a g A p b f G p a e F

    Beethoven's 9th symphony theme:

    f f f # C # d # d # d C p f f f # c # f #f # f f +# c + # c + # c # A ff f c # f # f # f f + # d + # d + # d

  • Siemens Composer Format

    Inspector Gadget theme:

    C2(1/8) D2(1/16) Dis2(1/8) F2(1/16) G2(1/8)

    P(1/16) Dis2(1/8) P(1/16) Fis2(1/8) P(1/16)

    D2(1/8) P(1/16) F2(1/8) P(1/16) Dis2(1/8)

    P(1/16) C2(1/8) D2(1/16) Dis2(1/8) F2(1/16)

    G2(1/8) P(1/16) C3(1/8) P(1/16) B2(1/2) P(1/4)

    C2(1/8) D2(1/16) Dis2(1/8) F2(1/16) G2(1/8) P(1/16)

    Dis2(1/8) P(1/16) Fis2(1/8) P(1/16) D2(1/8) P(1/16)

    F2(1/8) P(1/16) Dis2(1/8) P(1/16) C3(1/8) B2(1/16)

    Ais2(1/8) A2(1/16) Gis2(1/2) G2(1/8) P(1/16) C3(1/2)

  • Motorola Composer

    Beethoven's 9th symphony:

    4 F2 F2 F2 C#4 D#2 D#2 D#2 C4 R2 F2 F2 F2 C#2 F#2 F#2

    F#2 F2 C#+2 C#+2 C#+2 A#4 F2 F2 F2 C2 F#2 F#2 F#2 F2

    D#+2 D#+2 D#+2

  • Panasonic Composer

    Beethoven's 9th symphony:

    444** 444** 444** 1111* 4444** 4444** 4444** 111*

    0** 444** 444** 444** 1111** 4444** 4444** 4444**

    444** 11** 11** 11** 6666* 444** 444** 444** 111**

    4444** 4444** 4444** 444** 22** 22** 22**

  • Sony Composer

    Beethoven's 9th symphony:






16.4 Running AudioDemo

Demonstrates audio capabilities, including mixing and playing audio with an animation. Select a MIDlet from the list, and from the menu, select 1, Launch.

16.5 Running MMAPIDemos

The MMAPIDemos application contains four MIDlets that showcase the SDK's multimedia capabilities:

16.5.1 Simple Tones

Simple Tones demonstrates how to use interactive synthetic tones. Select a sample, then click Play on the lower right.

  • Short Single Tone and Long Single Tone use Manager.playTone() to play tones with different pitch.

  • Short MIDI event plays a chord on the interactive MIDI device (locator "device://midi"). The shortMidiEvent() method of MIDIControl is used to trigger the notes of the chord.

  • To run the MMAPI Drummer demo, click or type number keys (0-9). Each number plays a different sound.

16.5.2 Simple Player

The Simple Player application demonstrates the range of audio and video capabilities of the emulator. It includes sample files in a variety of formats and can play files from the emulator's persistent storage or from HTTP URLs.

The player portion uses a generic interface. The player displays duration, media time, and controls for running the media file. If metadata is available in a file, the player enables you to view the information, such as author and title. In the case of MIDI files, if karaoke text is present in the file, it displays on the screen during play. Graphical user interface controls can be viewed on the display screen if applicable. You can access these controls by selecting one of the media samples in Simple Player, then pressing the Menu button to view and select the desired command.

Select Simple Player then click Launch. The demo includes the following media samples:

  • Bong plays a short WAV file. You can adjust certain playback features, as described later in this document. The display shows the duration of the sound in minutes:seconds.tenths of a second, for example 00:01.04. This audio sample is a resource file in the MIDlet suite JAR file.

  • MIDI Scale plays a sample musical scale. The display shows the title of the selected music file, the duration of the song, the elapsed time during playback, and the current tempo in beats per minute (bpm). This MIDI file is stored in the MIDlet suite JAR file.

  • Simple Ring Tone plays a short sequence of Beethoven's Fifth Symphony. The display shows the title of the selected music file, the duration of the song, the elapsed time in seconds and tenths of a second during playback, and the current tempo in beats per minute (bpm). This ring tone file (.jts format) is stored in the MIDlet suite JAR file.

  • WAV Music plays a brief audio file. The display shows the title of the audio file, the duration of the audio the elapsed time during playback, and the playback rate in percent. This WAV file is retrieved from an HTTP server.

  • MIDI Scale plays a MIDI file that is retrieved from an HTTP server.

  • The Animated GIF example shows an animated GIF that counts from 1 to 5. The file is stored in the MIDlet suite JAR file.

  • AMR Narrow band. Plays an Adaptive Multi-rate narrow band file. This sample requires an AMR codec. This sample was tested with the K-Lite Mega Codec Pack 4.8.0. This codec is freely downloadable.

  • Audio Capture from a default device lets you capture audio from a microphone or connected device. The sound is captured and played back on the speaker. To avoid feedback, use a headset.

  • Video Capture Simulation simulates viewing input video. For example, on a device equipped with a camera.

  • [enter URL] Plays back media files from arbitrary HTTP servers. Type a valid URL at the insertion point and click OK to play a file. If you want to open an HTTP directory from which to select media, be sure to add a slash to the end of the URL.

In addition, Simple Player parses ring tones in Ringing Tones text transfer language (RTTTL). See for information on RTTTL.

The Simple Player menu lists commands that control media playback.

The first menu item, Quick Help, displays a list of commands and actions mapped to keypad buttons. Some actions are not applicable for every media type.

The remaining menu items vary depending on the media type. Some actions, such as Rate, open a control with which you can arbitrarily change the playback. Click Back to return to the player screen and see or hear your changes.

16.5.3 Video

The Video application illustrates how the emulator is capable of playing animated GIF files and capturing video. On a real device with a camera, video capture shows the user what the camera sees.

Animated GIFs and video capture can be implemented using either a Form Item or a Canvas. The Video demonstration includes all the possibilities.

  • Animated GIF - Form [jar] shows an animated GIF in a Form. A simple indicator shows the progress through the animation.

  • Animated GIF - Canvas [jar] shows an animated GIF in a Canvas. A simple indicator shows the progress through the animation.

  • Video Capture - Form simulates capturing video from a camera or other source and showing it as an Item in a Form. Choose the Snapshot command to take a snapshot of the captured video. The snapshot is placed beneath the video capture for comparison.

  • Video Capture - Canvas simulates capturing video from a camera or other source and showing it in a Canvas. Choose Snapshot to get a still image of the current appearance. The snapshot is shown briefly, then the display goes back to the video capture.

16.5.4 Pausing Audio Test

This test MIDlet demonstrates the proper use of pauseApp()and the alternative.


Do not run the memory monitor while using this demo.

In the Well-Behaved case suspending uses pauseApp() to close the player and remembers the length of time the audio file played. When the player resumes, it starts playing the audio file at the point that it was suspended.

In the Not Well-Behaved case the player is stopped instead of suspended. When the player is restarted the audio file plays from the beginning.

Test the two cases as follows:

  • Run MMAPIDemos, and launch Pausing Audio Test.

    The music starts playing. The initial value of Current State is Well-Behaved.

  • Select Application > Suspend (or F5), to pause the music.

  • Select Application > Resume (or F6) to resume playing the audio clip from the stopping point.

  • Click the Misbehave soft key.

  • Select Application > Suspend (or F5), to stop the music.

  • Select Application > Resume (or F6). The player restarts but the clip plays from the beginning.