Mobile Media API Overview

zhaozj2021-02-11  158

Author: than Knudsen compilation: Sean

Mobile Media API (MMAPI) provides a powerful, expandable, and simple interface for multimedia development. It has a set of specifications played and recorded AUDIO or VIDEO interfaces. This article is an overview of the MMAPI concept and a quick tutorial used by its classes and interfaces.

The architecture of the Mobile Media API is based on four basic concepts: 1. A Player knows how to explain the media data. For example, some type of Player knows how to generate sound according to MP3 media data. Another Player knows how to play the Movie of one end QuickTime. The implementation of the javax.microedition.media.Player interface is both the Player here.

2. You can use one or more Controls to adjust the behavior of Player. You can get from a Player instance from a Player instance when playing data from the media from the media and uses Controls. For example, you can use a VolumeControl to adjust the sound size of a sampled audio. Controls is the implementation of the javax.microedition.media.control interface. The detailed Control sub-interface is in the javax.microedition.media.control package 3. A Data Source knows how to read the media data from its original location to Player. Media data can be saved in different locations, from remote servers to resource files or RMS databases. Media data can be transmitted from the original location through HTTP, streaming like RTP, or transferred to Player. Javax.microedition.media.protocol.dataSource is an abstract parent class for all Data Source classes in MMAPI. 4. Finally, Manager bundles each component and provides an entry point for the API. The javax.microedition.media.manager class contains a static method of getting Player or DataSource.

Use MMAPI

The easiest thing you can use by Manager is to play a piece of Tone with the following method:

Public Static Void Playtone (int Note, Int Duration, int volume) Throws MediaException

Playing time is defined in milliseconds, the volume range is from 0 (silent) to 100 (maximum). The notes are defined in a number, like MIDI, 60 represents the middle sound C, 69 is a 440 Hz A tone. The range of notes can range from 0 to 127. The Playtone () method is suitable for playing a single tone or a very short model. For longer mono modes, you can play all the models with the default music player.

MMAPI most charming places reflected in the createPlayer Manager method, the method has the following three different versions: public static Player createPlayer (String locator) throws IOException, MediaExceptionpublic static Player createPlayer (DataSource source) throws IOException, MediaExceptionpublic static Player createPlayer (InputStream Stream, String Type) Throws oException, MediaException Getting a Player The easiest way is to use the first CreatePlayer method, just pass a string representing the media data. For example, you can specify an audio file on a website: Player P = Manager.createPlayer ("http://webserver/music.mp3"); other CreatePlayer methods allow you to create Player from a DataSource or an InputStream stream. If you consider using Player, these three methods are real three different ways to get MedIA data. An InputStream is the simplest object, just a byte stream. DataSource is more advanced, it is an object that selection protocol to access media data. Passing a location string is the best shortcut: MMAPI will clear what protocol and acquire media data for Player. How to use Player

Once you have successfully established a Player object, what should I do next? The simplest action is to start playback with START methods. However, just to learn more deeper than getting deeper, this is conducive to help understand a Player's life cycle. This cycle consists of four states.

When a Player is established, its status is unrealized. After setting the media data for this Player, its status is realized. If Player is downloading and interpreting data from a server's HTTP connection, such as Player has been sent to the server at the HTTP request, and DataSource is ready to receive Audio data. The next state is prefetched, the timing to obtain this state is that the Player has read enough data to begin interpretation and calculation. Finally, when the data is completed, the status of the Player becomes started.

The Player interface provides a method of status conversion. In the status cycle, it is described whether it moves back or back. The reason is to provide an operational control to the application. Control may take a while. For example, you may want to push Player's realized status to the prefetched status, and play it immediately to respond to the user's operation.

MMAPI in Java Platform

What kind of case is MMAPI suitable for use in Java 2 Platform? The answer is almost anywhere. Although the MMAPI design is only based on CLDC, it can run well on CLDC and CDC software. In fact, MMAPI can be implemented as a lightweight to achieve J2SE to Java Media Framework.

Can you support those types of Media files?

If your device supports MMAPI, what type of media data can this device can play? What data transfer protocol is supported? Mmapi does not require any specified Content Type or protocol, but you can find what type of data supported by the program while running, by calling the GetSupportedContentTypes () method of the Manager class, and getsupportedProtocols (). What is the worst thing that may happen? If you give Player a non-supported data type or protocol through Manager, it will thrown an Exception. Your program should try to recover from such exceptions, which can show some polite information prompts to users. MIDP 2.0 media

The MIDP 2.0 specification includes a subset of MMAPI. It is compatible with all APIs. The MIDP 2.0 subset features: 1. Only audio playback (recording) is supported. Does not include a VIDEO control interface. 2. Multiple Player cannot be synchronized 3. The additional classes of the DataSource class and javax.microedition.media.Protocol package are not included; the application cannot implement their own protocol. 4. The Manager class is simplified. MIDP requires support for tone generation and sampling, WAV audio playback.

Summary MMAPI provides a simple, expandable and specified API for running from the Java application to run using multimedia from the mobile device line.

转载请注明原文地址:https://www.9cbs.com/read-5785.html

New Post(0)