Java Mobile Media API

Last updated

The Mobile Media API (MMAPI) is an API specification for the Java ME platform CDC and CLDC devices such as mobile phones. Depending on how it is implemented, the APIs allow applications to play and record sounds and video, and to capture still images. MMAPI was developed under the Java Community Process as JSR 135.

Contents

Programming concepts

The Multimedia Java API is based around four main types of classes in the javax.microedition.media package the Manager , the Player , the PlayerListener and various types of Control .

Java ME programmers wishing to use JSR 135 would first make use of the static methods of the Manager class. Although there are other methods such as playTone, the main method used is createPlayer. This takes either a URI or an InputStream , and a MIME type. In most cases, URIs are used. Common URI protocols used include:

The MIME type is optional, and is inferred from the data passed in if not supplied.

The createPlayer method returns an implementation of the Player interface (even if you use a capture: protocol URI). This has core methods that are applicable to all players, such as starting and stopping the media, and requesting that it loop. You can also setPlayerListener to an object implementing the PlayerListener interface, which will receive various events related to the clip (starting, stopping, media finishing, etc.)

Player classes also have a getControl method that returns an implementation of a particular Control. A Control handles any optional APIs which are not applicable to all media types. Any given Player may or may not be able to supply an implementation of any given Control.

(Typically, the Control returned is actually the Player itself, but this is not guaranteed to be the case.)

The set of controls implemented by a Player is not limited; however, some standard ones are defined in the javax.microedition.media.control package by the JSR:

Standard MMAPI Controls
Control InterfaceDescription
FramePositioningControlA control for video data that allows access to individual frames.
GUIControlA control for data that requires a display, such as video.
MetaDataControlUsed to determine the metadata information stored within amedia stream, such as title, copyright, author, and so on.
MIDIControlA fully functional control that enables access to a device’s MIDI player.
PitchControlUsed to control the pitch (frequency) of audio data.
RateControlUsed to control the playback rate of a Player.
RecordControlAllows you to control the recording of data from a capture device, such as video from a camera or audio from a sound recorder.
StopTimeControlA control that allows you to set a preset time when you want the Player to stop playing.
TempoControlSimilar to RateControl, this control allows you to change the tempo (speed) of playback for an audio Player, typically, a MIDI Player.
ToneControlA fully functional control that allows you to play monotonic tone sequences.
VideoControlExtends GUIControl and controls the display of video.
VolumeControlThe simplest control that allows you to control the volume of audio in a Player.

(Others may be defined in JSR 234 (Advanced Multimedia Supplements).

A subset of JSR 135 is defined in JSR 118 (MIDP 2.0).

Player lifecycle

Regardless of the protocol or media type involved, the Player moves through the same discrete states during its lifecycle. These states are listed in table below

Lifecycle states of a Player instance
StateDescription
UnrealizedInitial state when a Player is created. In this state the player does not have enough information to acquire the necessary resources to process the media.
RealizedThe Player moves into the Realized state once it has obtained the necessary information to acquire the resources. In this state it is likely that most of the resources have already been acquired to function. However, some resources may not have been acquired at this point, especially if there are system dependencies involved such as with an audio or video driver where exclusive access must be obtained.
PrefetchedThe Player moves into the Prefetched state once all resources have been acquired, including scarce and system dependent resources. Once in the Prefetched state, the Player has everything necessary to perform its tasks.
StartedA Player in the Started state indicates that the content associated with the Player is being processed.
ClosedA Player moves to the Closed state at the end of its lifecycle. A Player in the Closed state must not be used again.

Implementations

As with most Java ME specifications, implementations differ despite the best efforts of the specification authors to ensure consistency. Two obvious areas for differences are in the controls supported, and in the acceptable URI types in the first place. More obscure areas are whether mixing is supported; many games would like to play a MIDI music track and layer PCM sound effects on top.

Another source of extreme variance is in performance. For example, if an HTTP clip is requested, at what point does the clip get downloaded? The specification recognises this by providing two Player methods that can be called in advance of actually playing: realize and prefetch. Depending on the implementation, these may do some of the work of getting the clip into a playable state, thus making it quicker to actually play the clip when it is needed. Some implementations are sophisticated enough to actually stream a clip on request whilst it is being played.

Symbian OS contains a very complete implementation of JSR 135, but even this is highly dependent on the underlying multimedia capabilities of the device, and some device manufacturers may choose not to expose the more obscure parts of Java ME such as recording.

Implementation consistency is ensured by forcing all implementations to pass the Java Technology Compatibility Kit (TCK). This ensures that each supported URI schema, MIME type and Control is tested, but does not test every permutation of these optional parts.

Code example

packageorg.wikipedia;importjavax.microedition.midlet.*;importjavax.microedition.media.*;publicclassSimplePlayerextendsMIDlet{protectedvoiddestroyApp(booleanarg0)throwsMIDletStateChangeException{}protectedvoidpauseApp(){}protectedvoidstartApp()throwsMIDletStateChangeException{try{Stringurl="http://upload.wikimedia.org/wikipedia/commons/a/a0/Bass_sample.mid";Playerplayer=Manager.createPlayer(url);player.start();}catch(Exceptione){e.printStackTrace();}}}

See also

Bibliography

Related Research Articles

Jakarta Enterprise Beans is one of several Java APIs for modular construction of enterprise software. EJB is a server-side software component that encapsulates business logic of an application. An EJB web container provides a runtime environment for web related software components, including computer security, Java servlet lifecycle management, transaction processing, and other web services. The EJB specification is a subset of the Java EE specification.

The Jakarta Transactions, one of the Jakarta EE APIs, enables distributed transactions to be done across multiple X/Open XA resources in a Java environment. JTA was a specification developed under the Java Community Process as JSR 907. JTA provides for:

Java Platform, Micro Edition or Java ME is a computing platform for development and deployment of portable code for embedded and mobile devices. Java ME was formerly known as Java 2 Platform, Micro Edition or J2ME. As of December 22, 2006, the Java ME source code is licensed under the GNU General Public License, and is released under the project name phoneME.

Java Platform, Standard Edition is a computing platform for development and deployment of portable code for desktop and server environments. Java SE was formerly known as Java 2 Platform, Standard Edition (J2SE).

In computing, the Java API for XML Processing, or JAXP, one of the Java XML Application programming interfaces, provides the capability of validating and parsing XML documents. It has three basic parsing interfaces:

Mobile Information Device Profile (MIDP) is a specification published for the use of Java on embedded devices such as mobile phones and PDAs. MIDP is part of the Java Platform, Micro Edition framework and sits on top of Connected Limited Device Configuration (CLDC), a set of lower level programming interfaces. MIDP was developed under the Java Community Process. The first MIDP devices were launched in April 2001.

The Connected Limited Device Configuration (CLDC) is a specification of a framework for Java ME applications describing the basic set of libraries and virtual-machine features that must be present in an implementation. The CLDC is combined with one or more profiles to give developers a platform for building applications on embedded devices with very limited resources such as pagers and mobile phones. The CLDC was developed under the Java Community Process as JSR 30 and JSR 139.

Java Management Extensions (JMX) is a Java technology that supplies tools for managing and monitoring applications, system objects, devices and service-oriented networks. Those resources are represented by objects called MBeans. In the API, classes can be dynamically loaded and instantiated. Managing and monitoring applications can be designed and developed using the Java Dynamic Management Kit.

Java APIs for Bluetooth Wireless Technology (JABWT) is a J2ME specification for APIs that allows Java MIDlets running on embedded devices such as mobile phones to use Bluetooth for short-range wireless communication. JABWT was developed as JSR-82 under the Java Community Process.

Content Repository API for Java (JCR) is a specification for a Java platform application programming interface (API) to access content repositories in a uniform manner. The content repositories are used in content management systems to keep the content data and also the metadata used in content management systems (CMS) such as versioning metadata. The specification was developed under the Java Community Process as JSR-170, and as JSR-283. The main Java package is javax.jcr.

Java Application Descriptor (JAD) files describe the MIDlets that are distributed as JAR files. JAD files are commonly used to package Java applications or games that can be downloaded to mobile phones. Java applications enable mobile phones to interact functionally with online web services, such as the ability to send SMS messages via GSM mobile Internet or interact in multiplayer games. Some BlackBerry devices use JAD files for themes, while on some mobile phones without memory cards it is not possible to download any apps.

BD-J, or Blu-ray Disc Java, is a specification supporting Java ME Xlets for advanced content on Blu-ray Disc and the Packaged Media profile of Globally Executable MHP (GEM).

JSR 48 Java WBEM API Specification is a Java Specification Request developed under the Java Community Process. It specifies the Java language binding of the DMTF Common Information Model/Web-Based Enterprise Management standards. The JSR 48 Expert Group has completed the public review in 2006 and is now on the way to create a Technology Compatibility Kit in order to finalize the standard. The API can be regarded as stable.

Within computing, Jakarta Activation is a Jakarta EE API that enables developers to:

PDA Optional Packages for the J2ME Platform JSR 75 is a specification that standardizes access in the Java on embedded devices such as mobile phones and PDAs to data that resides natively on mobile devices. JSR 75 is part of the Java ME framework and sits on top of CLDC, a set of lower level programming interfaces. It has 2 main components. Not all devices that claim to implement JSR 75 will implement both components.

The phoneME project is Sun Microsystems reference implementation of Java virtual machine and associated libraries of Java ME with source, licensed under the GNU General Public License.

In computing, the Advanced Multimedia Supplements is an API specification for the Java ME platform. Practically speaking, it is an extension to JSR 135 Mobile Media API providing new features, such as positional 3D audio processing, audio and video effects processing, better controls for digital camera, and better support for analog radio tuner including Radio Data System. AMMS was developed under the Java Community Process as JSR 234.

Jakarta RESTful Web Services, is a Jakarta EE API specification that provides support in creating web services according to the Representational State Transfer (REST) architectural pattern. JAX-RS uses annotations, introduced in Java SE 5, to simplify the development and deployment of web service clients and endpoints.

<span class="mw-page-title-main">Nokia 2730 classic</span> 2009 cell phone model

The Nokia 2730 classic is a Nokia Quad-band GSM/UMTS 3G cell phone that includes a camera, FM radio, Bluetooth, music and video player, as well as several internet-based applications.

Java Database Connectivity (JDBC) is an application programming interface (API) for the Java programming language which defines how a client may access a database. It is a Java-based data access technology used for Java database connectivity. It is part of the Java Standard Edition platform, from Oracle Corporation. It provides methods to query and update data in a database, and is oriented toward relational databases. A JDBC-to-ODBC bridge enables connections to any ODBC-accessible data source in the Java virtual machine (JVM) host environment.