How to Make a Video Player for Java Phones
- 1). Include the classes from the Java ME API required for creating the video player. In this example, the following classes are used:
import javax.microedition.lcdui.*;
import javax.microedition.media.*;
import javax.microedition.media.control.*;
import javax.microedition.midlet.*; - 2). Create an instance of the Player and VideoControl classes.
Player myPlayer;
VideoControl myVideoController; - 3). Create a video player with the manager class through the static create-player call. In this example, the Uniform Resource Locator for the MPG movie is hard-coded into the sample, but can also be passed to the player dynamically based on user choice. The create-player call is called in a try loop to handle potential exceptions.
try {
myPlayer = Manager.createPlayer("http://www.rjsmunford.com/testmovie.mpg"); - 4). Obtain control of the video controller through the realize() method call and use of the video-control class static get-control method call.
myPlayer.realize();
myVideoController = (VideoControl)myPlayer.getControl("VideoControl"); - 5). Start the video player and end the try loop.
myPlayer.start();
} // end the try loop - 6). Catch Input and Media exceptions that can result from the video player instantiation.
catch(IOException myIOException) {
}
catch(MediaException myMediaE) {
}
Source...