Archive for the 'j2me multimedia' Category

View PNG Image with Thread

/*————————————————–
* ViewPngThread.java
*
* Download and view a png file. The download is
* done in the background with a separate thread
*
* Example from the book: Core J2ME Technology
* Copyright John W. Muchow http://www.CoreJ2ME.com
* You may use/modify for any non-commercial purpose
*————————————————-*/
[…]

Display Alert

//jad file (please verify the jar size)/*MIDlet-Name: DisplayAlertMIDlet-Version: 1.0MIDlet-Vendor: MyCompanyMIDlet-Jar-URL: DisplayAlert.jarMIDlet-1: DisplayAlert, , DisplayAlertMicroEdition-Configuration: CLDC-1.0MicroEdition-Profile: MIDP-1.0MIDlet-JAR-SIZE: 100
*/import javax.microedition.lcdui.Alert;import javax.microedition.lcdui.AlertType;import javax.microedition.lcdui.Command;import javax.microedition.lcdui.CommandListener;import javax.microedition.lcdui.Display;import javax.microedition.lcdui.Displayable;import javax.microedition.lcdui.Form;import javax.microedition.midlet.MIDlet;import javax.microedition.midlet.MIDletStateChangeException;
public class DisplayAlert extends MIDlet implements CommandListener { private Display display;
private Alert alert;
private Form form = new Form(”Throw Exception”);
private Command exit = new […]

Accessing Commands

/*————————————————–* AccessingCommands.java** Example from the book: Core J2ME Technology* Copyright John W. Muchow http://www.CoreJ2ME.com* You may use/modify for any non-commercial purpose*————————————————-*/import javax.microedition.midlet.*;import javax.microedition.lcdui.*;
public class AccessingCommands extends MIDlet implements CommandListener{ private Display display; // Reference to Display object private Form fmMain; […]

Animation Midlet

/*J2ME in a NutshellBy Kim TopleyISBN: 0-596-00253-X
*/
import java.util.Timer;import java.util.TimerTask;import javax.microedition.lcdui.Canvas;import javax.microedition.lcdui.Command;import javax.microedition.lcdui.CommandListener;import javax.microedition.lcdui.Display;import javax.microedition.lcdui.Displayable;import javax.microedition.lcdui.Form;import javax.microedition.lcdui.Gauge;import javax.microedition.lcdui.Graphics;import javax.microedition.lcdui.Item;import javax.microedition.lcdui.ItemStateListener;import javax.microedition.midlet.MIDlet;
public class AnimationMIDlet extends MIDlet implements CommandListener, ItemStateListener {
[…]

Capturing Video with J2ME

Illustration below takes pictures on a J2ME device.
import java.io.IOException;import javax.microedition.lcdui.*;import javax.microedition.media.*;import javax.microedition.media.control.*;import javax.microedition.midlet.MIDlet;import javax.microedition.media.control.VideoControl;
public class VideoMIDlet extends MIDlet implements CommandListener {
private Display display; private Form form; private Command exit,back,capture,camera; private Player player; private VideoControl videoControl; private […]

Font Demo J2ME

The Font class represents fonts and font metrics. Fonts cannot be created by applications. The setFont(Font font) method of graphic class sets the font for all subsequent text rendering operations. And there is no call to showNotify and hideNotify method on some the device. This application will help game developer to find out the exact […]

Playing local MP3

The method below creates player and play mp3 file.public void run(){ try { InputStream is = getClass().getResourceAsStream(”/your.mp3″); player = Manager.createPlayer(is,”audio/mpeg”);
player.realize(); // get volume control for player and set volume to max vc = (VolumeControl) player.getControl(”VolumeControl”); […]

Playing Video

MMAPI(Mobile Media API) provides a framework for playing media content on J2ME devices.There are protocols defined for real-time streaming of Internet radio content, streaming other RTP (Real-time Transport Protocol) content, capturing audio, and taking pictures.
The method below plays a video file the on mobile device:public void run(){ try { String […]