Miscellaneous
Miscellaneous
public void
addPlayerListener(PlayerListener player
Listener) Add a player listener for this
player.
Parameters:playerListener - the listener
to add. If null is used, the request will be
ignored.
removePlayerListener
public void
removePlayerListener(PlayerListener pl
ayerListener) Remove a player listener for
this player.
Parameters:
◦ playerListener - the listener to remove. If null
is used or the given playerListener is not a
listener for this Player, the request will be
ignored.
PlayerInterface
The player includes methods for adding
and removing listeners that will be
notified about events in the players life.
Public void
addPlayerListener(PlayerListener pl)
Public void
addPlayerListener(PlayerListener pl)
We can listen for the player’s events by
registering playerlistener objects to a player
instance.
It has one method playerUpdate(), which is
invoked every time the registered player
receives an event.
PlayerListener is the interface for receiving
asynchronous events generated by Players.
Applications may implement this interface and
register their implementations with the
addPlayerListener method in Player.
playerUpdate
PlayerListenerInterface Fields
Video Control Interface
This interface is available in the
javax.microedition.media.control package.
The purpose of the video control is to control
the video display.
This interface can be used to capture an image
as well as to play a video.
For this we need to create a player, realize it
then call start() on it to play the video.
For video only we need to change the content
type and the file extension.
For eg.. :
InputStream
is=getClass.getResource(“play1.mpg”);
Player p=Manager.createPlayer(is,”video/mpeg”);
Unlike audio that is played on speakers, video will
take up some space on the user interface.
Methods
MMAPI gives us two choices for this :
◦ Display video on custom canvas
◦ Display video on an item within a form
Display video on the canvas
Ifwe want to display the video on a custom canvas, we need to
derive a class from canvas.
The following code snippet can be used to position and display
the video.
Public MyVideo(VideoControl vc)
{
vc.initDisplayMode(VideoControl.USE_DIRECT_VIDEO,this);
vc.setDisplayLocation(5,5);
vc.setDisplaySize(getWidth()-50,getHeight()-50);
Vc.setVisible(true);
}
Displaying video on an item within
a form
Using an item to display the video allows
us to mix the with other items.
Eg:
(Item)mv=(Item)vc.initDisplayMode(Video
Control.USE_GUI_PRIMITIVE,null)
Form.append(mv);
Image
Once a camera video is shown on the device,
capturing an image is easy. All we need to do is
call VideoControl’s getSnapshot() method.
We need to pass an image type, or null for the
default type, PNG.
getSnapShot() returns an array of bytes, which
is the image data in the format we requested.
Byte[] raw=vc.getSnapshot(null)
Image
image=Image.captureImage(raw,0,raw.length);
Examples
ImageCaptureMidlet.java
Bluetooth/OBEX API
JSR 82
WMA API
The Wma is the Wireless Messaging API.
Nowadays we can use the internet on our mobile,
using which can transmit the text type of data.
But using internet will be quite costly in such
situation.
Another option is available which is low cost and
has become popular rapidly.
This low cost technique is SMS, which is one
type of messaging service usually for mobile
phones.
Cellular companies offer 3 types of
textual message :
◦ SMS
◦ CBS (cell broadcast services)
◦ USSD
The Wma is the Wireless Messaging API is an optional
api that enables midp applications to send and receive
SMS.
It can also be used to send CBS and MMS messages.
Unlike the cell phone call, a message is not lost if the
receiving phone is not available.
The SMS makes use of store and forward technique in
which the messages are queued until the receiving
device is available.
The WMA makes SMS available to MIDP developers.
Javax.microedition.messaging
package
It is based on the Generic Connection
Framework (GCF) and targets the CLDC.
It is possible to take advantage of WMA,
once JSR 197 is complete.
Components of WMA
Message Connection Message
MessageListener
TextMessage BinaryMessage
The above fig shows the interface of the
WMA v1.0 which are included in the
javax.wireless.messaging package. This
can be summarized as follows :
◦ Message
◦ TextMessage
BinaryMessage
◦ MessageConnection
◦ MessageListener