if noone knows this problem, maybe one of you could test it on your pc just to let me know I'm not completely stupid...
my "startscreen":
Code:
import net.rim.device.api.ui.component.RichTextField;
import net.rim.device.api.ui.container.MainScreen;
public class StartScreen extends MainScreen{
public StartScreen(){
this.add(new RichTextField("HELLO"));
this.add(new VideoScreen());
}
}
and the mainpart, the "videoscreen":
Code:
import java.io.IOException;
import javax.microedition.media.Manager;
import javax.microedition.media.MediaException;
import javax.microedition.media.Player;
import javax.microedition.media.PlayerListener;
import javax.microedition.media.control.VideoControl;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.Keypad;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.container.HorizontalFieldManager;
public class VideoScreen extends HorizontalFieldManager implements FieldChangeListener,PlayerListener{
ButtonField startButton1;
Player mp;
public VideoScreen(){
startButton1 = new ButtonField("start1",ButtonField.CONSUME_CLICK);
startButton1.setChangeListener(this);
try {
mp = Manager.createPlayer("file:///store/samples/videos/BlackBerry.mp4");
mp.realize();
VideoControl videoControl = (VideoControl)mp.getControl( "javax.microedition.media.control.VideoControl");
videoControl.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, this);
// if this line is not commented out the error will appear...WHY???
//videoControl.setDisplaySize(224, 168);
// this line would work fine:
//videoControl.setDisplaySize(320, 200);
// this line wouldn't:
//videoControl.setDisplaySize(318, 240);
videoControl.setVisible(true);
} catch (IOException e) {
System.out.println("1"+e);
e.printStackTrace();
} catch (MediaException e) {
System.out.println("2"+e);
e.printStackTrace();
}
this.add(startButton1);
}
public void fieldChanged(Field field, int context) {
System.out.println("start..");
ButtonField button;
if(field instanceof ButtonField){
button = (ButtonField) field;
if(button == startButton1){
try {
mp.start();
} catch (MediaException e) {
System.out.println("3: "+e);
e.printStackTrace();
}
}
}
}
public void playerUpdate(Player player, String event, Object eventData) {
// TODO Auto-generated method stub
}
public boolean keyDown(int keycode, int time) {
if(Keypad.map(keycode) == Keypad.KEY_SPACE){
try {
mp.setMediaTime(mp.getMediaTime()-2000000);
} catch (MediaException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else if(Keypad.map(keycode) == Keypad.KEY_ESCAPE){
try {
mp.stop();
} catch (MediaException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return(true);
}
}
Any ideas?????
Thanks in advance
JJ
EDIT: by the way: the same error occurs when I use
Code:
Field videoField = (Field)videoControl.initDisplayMode( VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field" );
and no Exception is thrown...