Embedding multimedia capabilities in a MIDlet is the next step in the evolution of MIDlets. Sun recognized early that audio and video are the future and introduced the Mobile Media API (MMAPI) via Java Specification Requests (JSR) 135(http://www.jcp.org/en/jsr/detail?id=135).
The biggest requirement of the MMAPI specification was to ensure compatibility with small footprint devices while creating a specification that would be scalable for future—possibly more capable—devices. To this end, MMAPI has succeeded tremendously.
This article introduces you to MMAPI and explains several factors that make it a successful specification. You'll learn how this API fits in the overall scheme for MIDlet creation with the Mobile Information Device Profile (MIDP) 2.0. The article concludes with information on the current list of devices that support this API.
What Is Mobile Media API (MMAPI)?
MMAPI is the optional API that developers use to embed advanced multimedia capabilities in any Java-enabled device. If you've been using the audio capabilities in MIDP 2.0, you've already been using a subset of MMAPI. This subset is a forward compatible version of MMAPI created for limited-capability devices.
MMAPI allows you to create applications for Java-enabled devices that can discover and use the multimedia capabilities of the device that they are running on. You can play different formats of audio and video files from the network, a record store, or a Java Archive (JAR) file; haveadvanced control over the playback of these files; capture audio and video and take snapshots; play MIDI files; generate and play back tones; stream radio over the network; and do a whole lot more.
To encourage device manufactures to use this API in their Java-enabled devices, MMAPI was designed specifically to be protocol and format agnostic. In other words, this API does not come with assumptions about the supported protocol for accessing multimedia content, nor does it makes assumptions about the formats that it would be able to play. Thus, different device manufactures implement this API in their own way and make it available with the protocols and formats that their devices can support. This characteristic makes MMAPI a high-level interface and allows it to be compatible with any Java configuration.
Most devices, however, support some basic protocols and formats; for example, most allow you to access media over HTTP and play the WAV file format for audio and MP3 for video.
If a device supports a particular media format, MMAPI may mandate some control over the functionality of that format to create control uniformity across different devices. Other formats may require entirely different controls that may or may not be mandatory.
MMAPI Features and Requirements
MMAPI was designed for Java-enabled mobile devices, but the design is intentionally general enough that any Java-enabled device can benefit from it. This forced a set of rules on the API designers that they had to adhere to:
- Low footprint API: Because the main target of this API is Java-enabled mobile phones, which are severely constrained for available memory, the API must be able to support media playback in the available memory. Typically, because the Java-enabled mobile phones run on the Connected Limited Device Configuration (CLDC), the memory available ranges between 128KB and 512KB. This is the memory available for the virtual machine, the core libraries, your MIDlets, and MMAPI. MMAPI's place with MIDP is covered in the "How Does MMAPI Fit with MIDP 2.0?" section later in this article.
- Ability to support multiple media types: By defining the core API as a set of interfaces, MMAPI is protocol and format agnostic. Device manufactures supply their own implementation of MMAPI and implement interfaces that support the multimedia capabilities of their devices. This allows a wide range of protocols and formats to be supported based on the device, without any hard wiring of protocols and formats built-in the API itself. This makes MMAPI immensely scalable as new formats are discovered and sup-ported by device manufacturers.
- Support for basic controls: Although the previous requirement states that MMAPI is protocol and format agnostic, some support for basic controls is guaranteed to be present. This creates uniform procedures for managing media, whatever format or protocol it may take. For example, all media can be played, started, or stopped.
- Support for device capabilities discovery: Similar to the previous requirement, all devices can be queried to discover their capabilities. This allows you to find out which protocols or formats the device supports.
- Support for basic audio and tone generation: Because MMAPI uses CLDC as the base minimum supported configuration, it requires some support for audio playback and tone generation. Note that the API mandates support for audio playback but doesn't restrict it to any particular format or protocol, in keeping with the ability to support multiple media types requirement. Device manufacturers are free to choose which format or playback they will support. Tone generation is important in Java-enabled mobile phones, and therefore, the API provides simple ways to play tones as well.
These requirements have led to an API interface that is truly extensible and capable of supporting a range of multimedia formats and protocols on an array of devices.
How Do I Get MMAPI?
If you have used the Java Wireless Toolkit (http://java.sun.com/products/sjwtoolkit/ download-2_3.html) to develop your MIDlets, you already have MMAPI installed. The Toolkit comes with a reference implementation (RI) of this API installed as an optional package. Of course, MIDP 2.0 contains a subset of this API, so if you are only going to use a limited subset of MMAPI, you don't need this RI.
Most development environments (such as Netbeans and Eclipse) that support mobile application development include a version of this Toolkit, so MMAPI is included as an optional package.
Of course, the RI supplied with the Toolkit may not be your target platform (in all likelihood, it won't be your target platform because it contains only virtual devices). For example, you may be developing applications for the mobile devices supplied by Nokia. In which case, you need to download the implementation of MMAPI supplied by Nokia for its devices. This implementation will come bundled with the Toolkit supplied by Nokia (http://forum.nokia.com/main/ 0,,034-2,00.html). Similarly, different device manufacturers, and not just mobile device manufacturers, will supply their own implementations bundled in with their overall Java Wireless Toolkit.
In short, to start developing multimedia applications for Java-enabled devices using MMAPI, you need the Java Wireless Toolkit supplied by the device manufacturers. The last section in this article points you to some popular Toolkits. The Sun Wireless Toolkit will be integrated in the Netbeans Integrated Development Environment (IDE) (http://www.netbeans.org), which will be the main development environment for the examples. The Motorola device emulators will be used to test the MIDlets before deploying them on an actual Motorola device (the Motorola C975).