The mobile media API in J2ME provides a frmaework for embedded facilities in mobile devices that support java platform. The MMAPI comes under the specification of the Java technology for wireless industry specification. The MIDP 2.0 also comes with a subset of MMAPI specification that allow mobile devices to play multimedia. On the other hand MMAPI is provided as an optional package in Java ME. The MMAPI includes a high level interface so that mobile devices support audio and video playback. An important advantage of MMAPI is that applications developed using MMAPI are not protocol or device specific. This enables different application developers to implement these APIs in their mobile devices independent of the application format. Also, the MMAPI supports both CLDC and CDC configurations. The basic features of MMAPI are as listed below.
- It provides support for a wide range of audio and video formats
- It enables new features to be added to the existing specification without modifying the older version.
- It provides a flexible and extensible framework.
- The processing requiremeents of MMAPI is limited.
- It requires very less memory.
- It consumes only a limited amount of resources.
javax.microedition.media Package
The javax.microedition.media package provides multimedia audio support. This package also supports the MIDP 2.0 specification. This package includes the classes and interfaces that provide audio support. The following interfaces are includes in this package.
The javax.microedition.media package provides multimedia audio support. This package also supports the MIDP 2.0 specification. This package includes the classes and interfaces that provide audio support. The following interfaces are includes in this package.
- The Control interface
- The Controllabe interface
- The Player interface
- The PlayerListener interface
The code for implementing the player listener interface is as shown below
Player myplayer = Manager.createPlayer("/filename.mp3");
myplayer.setLoopCount(10);
myplayer.start();
A simple j2me program to play an audio file is shown below
Player myplayer = Manager.createPlayer("/filename.mp3");
myplayer.setLoopCount(10);
myplayer.start();
A simple j2me program to play an audio file is shown below
import javax.microedition.midlet.*;
import javax.microedition.media.*;
public class Audiosample extends MIDlet
{
public void startApp()
{
try
{
Player myplayer = Manager.createPlayer(getClass()
.getResourceAsStream("nature.wav"),"audio/x-wav");
player.start();
}
catch(Exception e)
{}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
{
}
}

No comments:
Post a Comment