I'm trying to play a video using j2me api I have the following code
But for some reason the video doesnt apear on the emulator.
I'm using netbeans IDE with the sun emulator.
Can you please let me know if i need to tweak this code to see the actual video on the emulator ?
Thanks
Prasanna
Expand|Select|Wrap|Line Numbers
- package p2;
- import java.io.*;
- import javax.microedition.io.*;
- import javax.microedition.midlet.*;
- import javax.microedition.lcdui.*;
- import javax.microedition.media.*;
- import javax.microedition.media.control.VideoControl;
- public class p2 extends MIDlet implements CommandListener {
- private Form form;
- public void startApp() {
- if (form == null)
- {
- form = new Form("Content types and protocols");
- Command exitCommand = new Command("Exit", Command.EXIT, 0);
- form.addCommand(exitCommand);
- form.setCommandListener(this);
- }
- try
- {
- String url = "http://today.java.net/today/2005/09/27/promo.mpg";
- Player p = Manager.createPlayer(url);
- p.realize();
- //Get the video controller
- VideoControl video = (VideoControl) p.getControl("VideoControl");
- //Get a GUI to display the video
- Item videoItem = (Item)video.initDisplayMode(
- VideoControl.USE_GUI_PRIMITIVE, null);
- //Append the GUI to a form
- form.append(videoItem);
- //Start the video
- p.start();
- }
- catch(Exception e)
- {}
- Display.getDisplay(this).setCurrent(form);
- }
- public void pauseApp()
- {
- }
- public void destroyApp(boolean unconditional)
- {
- }
- public void commandAction(Command c, Displayable s)
- {
- notifyDestroyed();
- }
- }