In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you what is the use of Mobile Media API, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Mobile Media API (MMAPI) provides a powerful, extensible and simple interface for multimedia development. It has a set of standard playback and recording audio.
Or the interface of video. This article is an overview of MMAPI concepts and a quick tutorial on the use of its classes and interfaces.
The architecture of Mobile Media API
MMAPI is based on four basic concepts:
one. A player knows how to interpret media data. For example, some type of player knows how to generate sound based on mp3 media data. Another player.
Know how to play the movie of one end of QuickTime. The implementation (implement) of the javax.microedition.media.Player interface is what we call player here.
two. You can use one or more controls to adjust the behavior of player. You can convert data from a player instance when player converts data from media
Get and use controls. For example, you can use a VolumeControl to adjust the volume of a sampled audio.
Controls is the implementation of the javax.microedition.media.Control interface. The detailed Control subinterface is in the javax.microedition.media.control package
three. A data source knows how to read media data to player from its original location. Media data can be stored in different locations, from remote servers to
Resource files or RMS databases. Media data can be transferred from the original location to player via HTTP, a streaming protocol like RTP, or other mechanisms.
Javax.microedition.media.protocol.DataSource is the abstract parent class of all data source classes in MMAPI.
four. Finally, manager bundles each part and provides an entry point for API. The javax.microedition.media.Manager class contains
Get the static method of Player or DataSource.
Use MMAPI
The easiest thing you can do with Manager is to play a piece of music (tone) in the following ways:
Public static void playTone (int note
Int duration, int volume) throws MediaException
The playback time is defined in milliseconds, and the volume ranges from 0 (silent) to 100 (maximum sound). The note is defined by a number, like MIDI, 60 represents the alto C.
69 is a 440 Hz A tone. Notes can range from 0 to 127. The playTone () method is suitable for playing a single tone or a very short modular tone.
For longer mono mode input, you can use the default music player, which can play a full mode feed.
The most fascinating thing about MMAPI is in Manager's createPlayer method, which has three different versions:
Public static Player createPlayer (String locator)
Throws IOException, MediaException
Public static Player createPlayer (DataSource source)
Throws IOException, MediaException
Public static Player createPlayer (InputStream stream, String type)
Throws IOException, MediaException
The easiest way to get a Player is to use the first createPlayer method, simply passing a string that represents 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 a Player from a DataSource or an InputStream stream. If you consider using Player
These three methods are really three different ways to get media data. An InputStream is the simplest object, just a stream of bytes. And DataSource
It is a bit more advanced and is an object that chooses a protocol to access media data. Passing a location string is the best shortcut: MMAPI will figure out which protocol to use and
Get media data for player.
How to use Player
Once you have successfully created a Player object, what should you do next? The easiest thing to do is to start replaying using the start method. However, only in order to learn how to get started.
Something deeper, which helps to understand the life cycle of an Player. This cycle consists of four states.
When a Player is first created, its status is UNREALIZED. After setting the location of the media data for this Player, its status is REALIZED.
If Player is downloading and interpreting data from a server's HTTP connection, for example, Player receives HTTP when a Http request has been sent to the server
After the response, and when the DataSource is ready to receive audio data. The next state is PREFETCHED, which is obtained when the player has read
There is enough data to begin to explain and calculate. Finally, when the data is finished, the state of Player becomes STARTED.
The Player interface provides a method of state transition, and in the state loop, both forward and backward are described. The reason is to provide an operable control to the application.
Control may take a while. For example, you might want to push the REALIZED state of Player to PREFETCHED so that a sound can be played immediately in response
The actions of the user.
In the MMAPI of java Platform
What kind of situations does MMAPI apply in java 2 platform? The answer is almost anywhere. Although the design of MMAPI was only based on CLDC, it can
It works well on both CLDC and CDC software. In fact, MMAPI can be implemented to java media Framework with j2se as a lightweight option.
What types of Media files can be supported?
If your device supports MMAPI, what type of media data can the device play? What data transfer protocols are supported? MMAPI does not require any specification
But you can find out what type of data the program supports at run time by calling getSupportedContentTypes () of the Manager class
Method and the getSupportedProtocols () method.
What's the worst thing that could happen? If you give Player an unsupported data type or protocol through Manager, it will throw an exception.
Your program should try to recover from such exceptions by displaying polite messages to the user.
Media for MIDP 2.0
The MIDP 2.0 specification includes a subset of MMAPI. It is upwards compatible with all API. The MIDP 2.0 subset has the following features:
one. Only audio playback (recording) is supported. The video control interface is not included.
two. Multiple Player cannot be synchronized
three. The DataSource class and other classes in the javax.microedition. Media.packages package are not included.
Applications cannot implement their own protocols.
four. The Manager class is simplified.
MIDP requires support for music generation and sampling, and WAV audio playback.
The above is all the content of this article "what's the use of Mobile Media API?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.