MobileJava MEIntroducing Mobile Media API (MMAPI)

Introducing Mobile Media API (MMAPI)

Developer.com content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

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 imple­mentation 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 pres­ent. 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 implemen­tation 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).

How Does MMAPI Fit with MIDP 2.0?

MMAPI is an optional package for the Java Micro Edition (ME) platform. MIDP 2.0 is a profile for the development of MIDlets, or applications for Java-enabled mobile devices, such as mobile phones and PDAs. MMAPI can be used with not just MIDP 2.0, but with any Java ME profile and configuration, provided an implementation is available for the device you are developing for. Refer to Beginning J2ME: From Novice to Professional, Third Edition, by Jonathan Knudsen and Sing Li (Apress, 2005) for a review of configurations, profiles, and development of MIDlets.

As you may already know, MMAPI is not the only optional package available for developing applications for the Java ME platform. Other prominent packages include the Web Services API (JSR 172), the Mobile 3D Graphics API (JSR 184), and the Location API (JSR 179). All of these optional packages, like the MMAPI package, are applicable to all available configurations, such as CLDC and Connected Device Configuration (CDC). On the other hand, an optional package such as the Wireless Messaging API (JSRs 120/205) is only relevant to the CLDC-based MID profile (MIDP).

MMAPI differs from the other optional packages because a scaled down version of it is present in MIDP 2.0 under the javax.microedition.media and javax.microedition.media.control packages. No other optional package makes an appearance in MIDP 2.0. So if you are develop­ing applications that only require basic audio control, you don’t need the full MMAPI installed or available. You would still be using MMAPI, just not the optional and bigger part of it. Your application will run on all devices that support MIDP 2.0, as MIDP 1.0 does not have the scaled version.

Note: Some devices support the MMAPI in MIDP 1.0 as an optional library, for example, Nokia 3650, Nokia 7650, and Sony Ericsson 610. Applications that use the features of the optional package will only run on devices that have both MIDP 2.0 and the optional MMAPI package installed. The next section includes a comprehen­sive list of all such devices at the time this article was written.

Figure 1 gives a bird’s eye view of how MMAPI, along with the other optional packages, fits in the development of applications for Java-enabled devices. Because this article concentrates on applications developed using MIDP, which are called MIDlets, I’ll use that term when talking about such applications.

Who Supports MMAPI?

The specification for MMAPI was developed using the Java Community Process (JCP) (http://www.jcp.org) by a consortium of organizations, including device manufacturers, network operators, and multimedia companies, besides Sun Microsystems. This specification is numbered 135 and can be accessed at http://www.jcp.org/en/jsr/detail?id=135. The initial expert group for the development of this specification was composed of Sun, Nokia, and Beatnik.

Afterwards, several other organizations chipped in and lent their support for the development of this specification. A final release with a version number of 1.0 occurred on June 27th, 2002. A maintenance release (version 1.1) incorporating security enhancements and minor modifications was released a year later on June 26th, 2003. Recently, JSR 234 has been released that identifies advanced supplements for this MMAPI.

As part of the development of this specification, Sun released a reference implementation of this API and a technology compatibility kit (TCK) that can be used to certify that an implementation of this API is compatible with the specification. This is par for any specification developed using the JCP. As stated earlier, this RI is bundled with the Java ME Wireless Toolkit supplied by Sun. Different device manufacturers supply their own implementations compatible with the TCK.

All devices that support MIDP 2.0 automatically support the scaled-down version of MMAPI. Many devices support the full version as an optional package. Table 1 gives a comprehensive list of devices that support MMAPI as an optional package.

Table 1: Devices That Support MMAPI As an Optional Package

Device Manufacturer Supported Devices Wireless Toolkit
Alcatel One Touch 756 http://www.my-onetouch.com
BenQ AX75 (MIDP 1.0), C70, C75, CF75/76, CL75, CX70/EMOTY, CX75, M75, S75, SL75, SXG75 http://www.benq.com/developer
Motorola C975, E1000, A1000, A630, A780, A845, C380, C650, E398, E680, SLVR, T725, V180, V220, V3, V300, V303, V360, V400, V500, V525, V550, V551, V600, V620, V635, V8, V80, V980, i730 http://www.motocoder.com
Nokia All Series 40, Series 60, and Series 80 based devices http://forum.nokia.com/main.html
Samsung E310, E380, E710, D400, P705, D410, 176X192 Series, E810, E310 http://uk.samsungmobile.com/club/
Sony-Ericsson W900, Z600, T610, T616, T618, V600, W800, K608, W550, W600, z520, D750, Z800, K600, K750, K300, K500, K700, J300, V800, Z500, S700, Z1010 http://developer.sonyericsson.com

Summary

This article introduced MMAPI, an optional package for the development of MIDlets that have embedded audio/video capabilities.

MMAPI provides these capabilities by defining a specification that is protocol and format agnostic, thereby increasing general acceptance and uptake. This has made MMAPI very popular and more and more devices support it.

About the Author

Vikram Goyal is a serious Java developer with over eight years’ of experience. Vikram is excited about J2ME and its prospects. He is an experienced writer and has published several well-known books in the industry. Vikram coauthored Beginning JSP 2, Second Edition with Apress, as well other titles from other well-known publishers.

Source of This Material

Pro Java ME MMAPI: Mobile Media API for Java Micro Edition
By Vikram Goyal

Published: May 2006, Paperback: 250 pages
Published by Apress
ISBN: 1-59059-639-0
Price: $49.99
eBook Price: $25.00
This material is Chapter 1 of the book.
Reprinted with the publisher’s permission.

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Latest Posts

Related Stories