Mobile Media API (mmapi) background

Chapter 10 - Media Using MIDP 2.0 and the MMAPI 1.1

    Mobile Media API (mmapi) background

  • Mobile Media API (MMAPI) background

              MMAPI defines the superset of the multimedia that are present in MIDP 2.0. It started life as JSR135 and is currently at version 1.1.

              The current version includes some documentation changes and security updates.It is distributed as an optional jar file in the J2ME wireless toolkit 2.2.

              The MMAPI is built on a high-level abstraction of all the multimedia devices that are possible in a resource-limited device.This abstraction is manifest in three classes that form the bulk of operations.

              These classes are the Player and Control interfaces,and the Manager class. Another class, the DataSource abstract class, is used to locate resources, but unless its reading data.

    Syntax with examples:
    Media Type Example syntax
    Capture audio "capture://audio" to capture audio on the default
    audio capture device or "capture://devmic0?encoding=pcm"
    to capture audio on the devmic0 device in the PCM encoding
    Capture video capture://video" to capture video from the default
    video capture device or "capture://devcam0?encoding=rgb888&width=100&height=50"
    to capture from a secondary camera, in rgb888 encoding mode and with a specified
    width and height
    Start listening in on the built-in radio "capture://radio?f=105.1&st=stereo" to tune
    into 105.1 FM frequency and stereo mode
    Start streaming video/audio/text from an external source "rtp://host:port/type" where type is one of audio,
    video or text
    Play tones and MIDI "device://tone" will give you a player that you
    can use to play tones or
    "device://midi" will give you a player that you
    can use to play MIDI

    The Manager Class

              The Manager class is the static factory class in the MMAPI. The createPlayer() method is the factory method used to create Player instances. Create Player from URI Locators

              The createPlayer() method takes in a URI locator string to specify the network location of the media file, or the data capturing mode, or the in-memory empty device type.

    static Player createPlayer (String locator)
    Create Player from Data Stream and MIME Type

              The URI locator–based approach is simple and powerful.This approach relies on the server to provide the correct MIME types.

              If the server is configured incorrectly, or if the network protocol does not support MIME metadata.

    Example:  Unix,socket

    static Player createPlayer (InputStream is, String type)
    Create Player from DataSource

              The createPlayer() method takes in a DataSource object to create a player. The DataSource class defines several abstract life cycle methods, which allow the users to  connect to a custom data source and start or stop data transfer.

              A DataSource instance contains one or multiple SourceStream objects, which manage the actual media data. The SourceStream is different from the InputStream.

                   •  SourceStream supports an API for random seeking that is required by some custom media data protocols.

                   •  SourceStream defines abstract methods to support the concept of transfer size that is more suited for frame-delimited data (e.g., video).


              The MMAPI specification declares the Player interface, which specifies the common behavior of all Player implementation classes provided by MMAPI implementers to handle different media types.

    Player Life Cycle

              CLOSED: The player has released most of its resources, and it can never be used again. It can change the player from any other state to the closed state by calling the Player.close() method.

              UNREALIZED: The player object has just been instantiated in the heap memory. It has not allocated any resources.

              REALIZED: If the Player.realize() method is called in a unrealized state, the player acquires required media resources and moves itself to the realized state.

              PREFETCHED: If the Player.prefetch() method is called, the player performs a number of potentially time-consuming startup tasks and moves itself to the prefetched state.

    Example: during the prefetching process, the player acquires controls over the camera, the speaker, or other exclusive resources.

              The prefetching could fail if another program is already using some of recourses. If the failure happens, call prefetch() later again on the same player.Once the player is prefetched, it can be started without further delay.

    STARTED: By calling the Player.start() method,can start the player, which starts the media playback or starts the capture player. Once the player is started,can also call the Player.

              stop() method to stop it and return it to the prefetched state. A stopped player can be started again, and it will resume playing from the point at which it was stopped.

© 2015 by Learncertification All Rights Reserved. The certification names are the trademarks of their respective owners. Terms & Privacy Policy