|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
help urgent required Java compiling error
A begginer in J2me, i am trying to produce a video player. There are two classes at present being VideoPlayerMIDlet and VideoPlayer. On compiling the two classes with wireless toolkit i recieve the following error.
\.....\.....\Src\VideoPlayerMIDlet.java:74: cannot resolve symbol symbol: method start () location: class VideoPlayerMIDlet start (); Okay, i understand why this is happening but not sure how to implement the solution. The VideoPlayerMIDlet contains the MIDlet functions such as startApp, pauseApp, destroyApp and the CommandAction methods. The command action has a command function to activate the start method which is contained in the VideoPlayer.class. Therefore it is unable to find the method as the CommandAction is located in the VideoPlayerMIDlet. Help would be most appreciated. I will print the code for the programme below: VideoPlayerMIDlet.class //import statements import javax.microedition.lcdui.*; import javax.microedition.midlet.*; import javax.microedition.media.*; public class VideoPlayerMIDlet extends MIDlet implements CommandListener, PlayerListener { public Display display; public Player player; public Command startCommand, exitCommand, stopCommand; private Form form; private TextField url; public VideoPlayerMIDlet() { display = Display.getDisplay(this); startCommand = new Command("Play", Command.SCREEN, 1); exitCommand = new Command("Exit", Command.SCREEN, 2); form = new Form("Demo Player"); url = new TextField("Enter URL:", "", 100, TextField.URL); form.append(url); form.addCommand(startCommand); form.addCommand(exitCommand); form.setCommandListener(this); display.setCurrent(form); } protected void startApp() { try { if(player != null && player.getState() == Player.PREFETCHED) { player.start(); }else { defplayer(); display.setCurrent(form); } }catch(MediaException me) { reset(); } } protected void pauseApp() { try { if(player != null && player.getState() == Player.STARTED) { player.stop(); }else{ defplayer(); display.setCurrent(form); } }catch(MediaException me) { reset(); } } protected void destroyApp(boolean unconditional) { form = null; try { defplayer(); }catch(MediaException me) { } } public void commandAction(Command c, Displayable s) { if(c == startCommand) { start(); // THIS IS WHERE THE PROBLEM LIES IT IS LOOKING FOR START() CONTAINED // IN VIDEOPLAYER.CLASS } //exit command if (c == exitCommand) { destroyApp(false); notifyDestroyed(); } } public void playerUpdate(Player player, String event, Object data) { if(event == PlayerListener.END_OF_MEDIA) { try { defplayer(); } catch(MediaException me) { } reset(); } } public void defplayer() throws MediaException { if(player != null) { if(player.getState() == Player.STARTED) { player.stop(); } if(player.getState() == Player.PREFETCHED) { player.deallocate(); } if(player.getState() == Player.REALIZED || player.getState() == Player.UNREALIZED) { player.close(); } } player = null; } void reset() { player = null; } } VideoPlayer.class /**class for player*/ import javax.microedition.media.*; import javax.microedition.media.control.*; import javax.microedition.lcdui.*; public class VideoPlayer implements Runnable { private VideoPlayerMIDlet controller; private TextField url; public VideoPlayer(VideoPlayerMIDlet controller) { this.controller = controller; } public void start() { Thread t = new Thread(this); t.start(); } public void run() { play(getURL()); } String getURL() { return url.getString(); } void play(String url) { try { VideoControl vc; controller.defplayer(); controller.player = Manager.createPlayer("http://www.leetambiah.pwp.blueyonder.co.uk/diss.mpg"); controller.player.realize(); vc = (VideoControl)controller.player.getControl("VideoControl"); if(vc != null) { Item video = (Item)vc.initDisplayMode ( vc.USE_GUI_PRIMITIVE, null); Form v = new Form("Playing Video..."); StringItem si = new StringItem("Status:", "Playing..."); v.append(si); v.append(video); v.addCommand(controller.startCommand); v.addCommand(controller.stopCommand); v.setCommandListener(controller); controller.display.setCurrent(v); } controller.player.prefetch(); controller.player.start(); }catch(Throwable t) { controller.reset(); } } |
|
#2
|
|||
|
|||
|
You will need an instance of the VideoPlayer class in the VideoPlayerMIDlet class then call the start method of that object rather than just start () on its own.
-KM- |
|
#3
|
|||
|
|||
|
How would i do this
thanks for reply but how would i do this.
In the videoPlayerMIDlet.class under the constructor i added VideoPlayer vp = new VideoPlayer(); then added vp.start(); However i then get identifier errors on the display, startCommand exitCommand etc |
![]() |
| Viewing: Dev Articles Community Forums > Programming > Java Development > help urgent required Java compiling error |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|