Error at Motorola v3x

HELP!!!

I installed a J2ME application on my Motorola v3x.

when i run the application i get the following error:

"Cannot create player"

The code seems to be OK, I checked it on some Sony Ericsson emulators. I didn't find a suitable emulators for my motorola device.

Here is the code:

package videoPlayer;

import javax.microedition.midlet.*;

import javax.microedition.lcdui.*;

/** A simple video player MIDlet using JSR 135 - Mobile Media API */

public class VideoPlayer extends MIDlet implements CommandListener

{

private Command exitCommand;

private Command playCommand;

private Command contentTypeCommand;

private Display display;

private TextField textField;

public Form form;

private Gauge gauge;

private static final int GAUGE_LEVELS = 4;

private static final int GAUGE_MAX = 12;

private static final String DEFAULT_URL = "http://localhost/test.mpg";

public VideoPlayer() {

display = Display.getDisplay(this);

form = new Form("Video Player");

textField = new TextField("Video URL", DEFAULT_URL, 100, TextField.ANY);

gauge = new Gauge("Acquiring video", false, GAUGE_MAX, 0);

exitCommand = new Command("Exit", Command.EXIT, 2);

playCommand = new Command("Play", Command.SCREEN, 1);

contentTypeCommand = new Command("Supported media types", Command.SCREEN, 2);

form.addCommand(playCommand);

form.addCommand(exitCommand);

form.addCommand(contentTypeCommand);

form.setCommandListener(this);

form.append(textField);

}

public void startApp(){

display.setCurrent(form);

}

public void pauseApp(){

}

public void destroyApp(boolean unconditional){

}

public void commandAction(Command c, Displayable s){

if(c == exitCommand){

destroyApp(false);

notifyDestroyed();

}

else if(c == playCommand){

gauge.setValue(0);

form.append(gauge);

VideoCanvas videoCanvas = new VideoCanvas(this);

videoCanvas.initializeVideo(textField.getString());

}

else if (c == contentTypeCommand){

String url = textField.getString();

int position = url.indexOf(':');

String protocol = url.substring(0, position);

SupportedTypes typesUI = new SupportedTypes(this, protocol);

display.setCurrent(typesUI);

}

}

public void updateGauge(){

int current = gauge.getValue();

current = (current + GAUGE_MAX/GAUGE_LEVELS);

gauge.setValue(current);

}

}

package videoPlayer;

import javax.microedition.lcdui.*;

import javax.microedition.media.*;

import javax.microedition.media.control.*;

import java.io.*;

/** Acquires the video content and renders it */

public class VideoCanvas extends Canvas implements CommandListener, PlayerListener, Runnable {

private VideoPlayer parent;

private Display display;

private Player player;

private VideoControl videoControl;

private String url;

private Thread initializer;

private Command close;

private Command rePlay;

public VideoCanvas(VideoPlayer parent){

super();

this.parent = parent;

display = Display.getDisplay(parent);

close = new Command("close", Command.SCREEN, 1);

addCommand(close);

setCommandListener(this);

}

public void initializeVideo(String url){

this.url = url;

initializer = new Thread(this);

initializer.start();

}

public void run(){

try {

player = Manager.createPlayer(url);

parent.updateGauge();

player.addPlayerListener(this);

player.realize();

parent.updateGauge();

player.prefetch();

parent.updateGauge();

} catch (IOException ioe) {

Alert alert = new Alert("IOException thrown", ioe.getMessage(), null, AlertType.ERROR);

display.setCurrent(alert);

} catch (MediaException me) {

Alert alert = new Alert("MediaException thrown", me.getMessage(), null, AlertType.ERROR);

display.setCurrent(alert);

}

playVideo();

}

public void playVideo(){

try {

// Get the video control and set it to the current display.

videoControl = (VideoControl)player.getControl("VideoControl");

if (videoControl != null) {

videoControl.initDisplayMode(videoControl.USE_DIRECT_VIDEO, this);

}

parent.updateGauge();

int cHeight = this.getHeight();

int cWidth = this.getWidth();

videoControl.setDisplaySize(cWidth, cHeight);

display.setCurrent(this);

videoControl.setVisible(true);

player.start();

} catch (MediaException me) {

Alert alert = new Alert("MediaException thrown", me.getMessage(), null, AlertType.ERROR);

display.setCurrent(alert);

}

}

/** Paints background color */

public void paint(Graphics g){

g.setColor(128, 128, 128);

g.fillRect(0, 0, getWidth(), getHeight());

}

public void playerUpdate(Player p, String event, Object eventData) {

//add "Replay" option when video is finished

if (event == PlayerListener.END_OF_MEDIA)

{

if (rePlay == null)

{

rePlay = new Command("re-play", Command.SCREEN, 1);

addCommand(rePlay);

}

}

}

public void commandAction(Command c, Displayable s) {

if(c == rePlay){

try{

player.start();

} catch (MediaException me) {

Alert alert = new Alert("MediaException thrown", me.getMessage(), null, AlertType.ERROR);

display.setCurrent(alert);

}

}

else if(c == close){

player.close();

parent.form.delete(1);

display.setCurrent(parent.form);

url=null;

parent=null;

}

}

}

[5901 byte] By [Elad_Levi1981a] at [2007-10-3 3:15:07]
# 1
To check your code first try to create player with one media file(added in .jar as resource) which supported by V3x.
himanshu17a at 2007-7-14 21:06:25 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2
Can you explane me how to add one media file into a jar file?Thanks
Elad_Levi1981a at 2007-7-14 21:06:25 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 3
look atdeveloper.motorola.comor http://developer.motorola.com/?path=1.2.6you can find the SDK and the simulator which can be merged into eclipse and NetBeans. It also has its own launcher. I am using it and it is very good.S.
sasanplusa at 2007-7-14 21:06:25 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 4

I downloaded and installed the SDK of Motorola and when i run my application i get the error:

"createPlayer() filed"

I added to my code the following lines:

String[] types = Manager.getSupportedContentTypes(protocol);

for(int i = 0; i < types.length; i++) {

append(new TextField("http", types, 20, TextField.ANY));

}

When i run the RAZR_v3x Emolator i get that the only video format which it supports is .mng, but i checked in Motorola web site about this device and i saw that it supports MPEG4, WMA, MP3 and Real Video/Audio files.

Do you something about that?

Thanks

Elad_Levi1981a at 2007-7-14 21:06:25 > top of Java-index,Java Mobility Forums,Java ME Technologies...