1、 外文: Embedding multimedia capabilities in aMIDlet 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
2、 of the MMAPI specification was to ensure compatibility with small footprint devices while creating a specification that would be scalable for future possiblymore capable devices. To this end, MMAPI has succeeded tremendously.This chapter introduces you to MMAPI and explains several factors that mak
3、e it a successful specification. You ll learn how this API fits in the overall scheme for MIDlet creation with theMobile Information Device Profile (MIDP) 2.0. The chapter concludes with information on the current list of devices that support this API. What Is Mobile Media API (MMAPI)? MMAPI is the
4、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. MM
5、API 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; have advanced control o
6、ver 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 pr
7、otocol 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 an
8、d 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
9、 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
10、 that may or may not be mandatory. Chapter 2 provides more information about mandatory controls for different formats in the “ Feature Sets Implementations” section. MMAPI Features and Requirements MMAPI was designed for Java-enabled mobile devices, but the design is intentionally general enough tha
11、t 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
12、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
13、s place with MIDP is covered in the “ How Does MMAPI Fit with MIDP 2.0?” section later in this chapter. 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 im
14、plement 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 discov
15、ered and supported 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
16、 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 bas
17、ic 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
18、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 AP
19、I 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:/ ) to develop your MIDlets, you already have MMAPI installed. The Toolkit comes with a reference im
20、plementation (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 developme
21、nt 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 applicatio
22、ns 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:/ ). Similarly, different device manufacturers, and not just mobile device ma
23、nufacturers,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 chapter
24、 points you to some popular Toolkits. In this book, I will develop multimedia MIDlets using the Sun supplied Java Wireless Toolkit 2.3 and the Motorola SDK V5.2 (http:/). In Chapters 8 and 9, I will also use the BenQ (formerly Siemens) CX 75 emulator (http:/ The Sun Wireless Toolkit will be integrat
25、ed in the Netbeans Integrated Development Environment (IDE) (http:/beans.org),which will be the main development environment for the examples in this book. The Motorola device emulators will be used to test the MIDlets before deploying them on an actual Motorola device (the Motorola C975), and Chapt
26、ers 8 and 9 will use the BenQ CX 75 emulator before testing them on the BenQ M75 device. 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, suc
27、h 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 (
28、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
29、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 on
30、ly 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 i
31、f you are developing 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. Yourapplication will run on all devices that support MIDP 2.0, as MIDP 1.0 does not have the sca
32、led version. 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
33、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
34、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, and is the version used for the examples in this book. 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