Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old June 26th, 2004, 09:38 AM
L_Tambiah L_Tambiah is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 2 L_Tambiah User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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();
}
}

Reply With Quote
  #2  
Old June 26th, 2004, 10:27 AM
kode_monkey kode_monkey is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 367 kode_monkey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 21 sec
Reputation Power: 6
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-

Reply With Quote
  #3  
Old June 27th, 2004, 05:15 AM
L_Tambiah L_Tambiah is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 2 L_Tambiah User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > help urgent required Java compiling error


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway