When I run my J2me project on my computer, the mobile phone device appears then two options appear. I select Install Application -> Launch. Then it will ask for a path [http://]
Where can I get that path?
Can you please attach screen shot of the issue, just to be sure what we are talking about
Can you please attach screen shot of the issue, just to be sure what we are talking about
attached is the print screen
OK, I will need to see code to know what is happening. Can you post your code?
I just copied that from http://www.roseindia.net/j2me/video-midlet.shtml to check if my setup is working
import java.io.*;
import java.util.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import javax.microedition.media.*;
import javax.microedition.media.control.*;
public class VideoPlayer extends MIDlet implements CommandListener, PlayerListener {
private Display display;
private List itemList;
private Form form;
private Command stop, pause, start;
private Hashtable items, itemsInfo;
private Player player;
public VideoPlayer() {
display = Display.getDisplay(this);
itemList = new List("Select an item to play", List.IMPLICIT);
stop = new Command("Stop", Command.STOP, 1);
pause = new Command("Pause", Command.ITEM, 1);
start = new Command("Start", Command.ITEM, 1);
form = new Form("Playing video");
form.addCommand(stop);
form.addCommand(pause);
form.setCommandListener(this);
items = new Hashtable();
itemsInfo = new Hashtable();
items.put("SpringWaterFall...", "file://SpringWaterFall.mpg");
itemsInfo.put("SpringWaterFall...", "video/mpeg");
items.put("helloboy...", "file://helloboy.mpg");
itemsInfo.put("helloboy...", "video/mpeg");
items.put("pilgrim...", "file://pilgrim.mpg");
itemsInfo.put("pilgrim...", "video/mpeg");
items.put("pirates...", "file://pirates.mpg");
itemsInfo.put("pirates...", "video/mpeg");
items.put("pythag1...", "file://pythag1.mpg");
itemsInfo.put("pythag1...", "video/mpeg");
items.put("CarelessEnglish...", "file://CarelessEnglish.mpg");
itemsInfo.put("CarelessEnglish...", "video/mpeg");
}
public void startApp() {
for(Enumeration en = items.keys(); en.hasMoreElements();) {
itemList.append((String)en.nextElement(), null);
}
itemList.setCommandListener(this);
display.setCurrent(itemList);
}
public void pauseApp() {
try {
if(player != null) player.stop();
} catch(Exception e) {}
}
public void destroyApp(boolean unconditional) {
if(player != null) player.close();
}
public void commandAction(Command c, Displayable d){
if(d instanceof List) {
List list = ((List)d);
String key = list.getString(list.getSelectedIndex());
try {
playAudio((String)items.get(key), key);
} catch (Exception e) {
System.err.println("Unable to play: " + e);
e.printStackTrace();
}
} else if(d instanceof Form){
try {
if(c == stop){
player.close();
display.setCurrent(itemList);
form.removeCommand(start);
form.addCommand(pause);
} else if(c == pause){
player.stop();
form.removeCommand(pause);
form.addCommand(start);
} else if(c == start){
player.start();
form.removeCommand(start);
form.addCommand(pause);
}
} catch(Exception e) {
System.err.println(e);
}
}
}
private void playAudio(String locator, String key) throws Exception {
String file = locator.substring(locator.indexOf("file://") + 6, locator.length());
player = Manager.createPlayer(getClass().getResourceAsStream(file), (String)itemsInfo.get(key));
player.addPlayerListener(this);
player.setLoopCount(-1);
player.prefetch();
player.realize();
player.start();
}
public void playerUpdate(Player player, String event, Object eventData) {
if(event.equals(PlayerListener.STARTED) && new Long(0L).equals((Long)eventData)) {
VideoControl vc = null;
if((vc = (VideoControl)player.getControl("VideoControl")) != null) {
Item videoDisp = (Item)vc.initDisplayMode(vc.USE_GUI_PRIMITIVE, null);
form.append(videoDisp);
}
display.setCurrent(form);
} else if(event.equals(PlayerListener.CLOSED)) {
form.deleteAll();
}
}
}
That is one of the reasons I personally that website. They will take (more of stealing) someone else tutorial and fail to acknowledge it and include any related resources. Your application is looking for resources, you need to get some other files and replace these mentioned in code
That's why it's asking for the url? Oh, now I get it. Thanks a lot!
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.