Skip to main content

[help] MediaComponent in LWUIT

3 replies [Last post]
zhenswx
Offline
Joined: 2008-07-13

Hi everyone , I use MediaComponent to capture photo,but there is a grey bar on top of my soft button bar , so I can't see the "Exit" Command! Can someone help me ? Thanks.

import com.sun.lwuit.Command;
import com.sun.lwuit.Display;
import com.sun.lwuit.Form;
import com.sun.lwuit.MediaComponent;
import com.sun.lwuit.events.ActionEvent;
import javax.microedition.media.Manager;
import javax.microedition.media.MediaException;
import javax.microedition.media.Player;
import javax.microedition.media.control.VideoControl;
import javax.microedition.midlet.MIDlet;

public class TryMidlet extends MIDlet {

private MediaComponent mc = null;
private Player player = null;
private VideoControl vc = null;
Form f = new Form("hello");

public void startApp() {
Display.init(this);
try {
player = Manager.createPlayer("capture://video");
player.realize();
player.start();
mc = new MediaComponent(player);
f.addComponent(mc);
vc = (VideoControl) player.getControl("VideoControl");
vc.setDisplayFullScreen(true);
f.addCommand(new Command("Exit") {

public void actionPerformed(ActionEvent arg0) {
release();
exitMIDlet();
}
});

f.show();
} catch (Exception e) {
}
}

private void release() {
if (player != null) {
try {
player.stop();
player.close();
} catch (MediaException ex) {
ex.printStackTrace();
}
}
}

public void exitMIDlet() {
destroyApp(true);
notifyDestroyed();
}

public void pauseApp() {
}

public void destroyApp(boolean unconditional) {
}
}

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Francis De Brabandere

see this post: http://forums.java.net/jive/thread.jspa?threadID=44377&tstart=30
(it's an emulator issue)

you can also try this if you have repaint issues with media players:
put the next line after Display.init():

Display.setFlashGraphicsBug(false);

On Tue, Jul 29, 2008 at 5:31 AM, wrote:
> Hi everyone , I use MediaComponent to capture photo,but there is a grey bar on top of my soft button bar , so I can't see the "Exit" Command! Can someone help me ? Thanks.
>
>
> import com.sun.lwuit.Command;
> import com.sun.lwuit.Display;
> import com.sun.lwuit.Form;
> import com.sun.lwuit.MediaComponent;
> import com.sun.lwuit.events.ActionEvent;
> import javax.microedition.media.Manager;
> import javax.microedition.media.MediaException;
> import javax.microedition.media.Player;
> import javax.microedition.media.control.VideoControl;
> import javax.microedition.midlet.MIDlet;
>
> public class TryMidlet extends MIDlet {
>
> private MediaComponent mc = null;
> private Player player = null;
> private VideoControl vc = null;
> Form f = new Form("hello");
>
> public void startApp() {
> Display.init(this);
> try {
> player = Manager.createPlayer("capture://video");
> player.realize();
> player.start();
> mc = new MediaComponent(player);
> f.addComponent(mc);
> vc = (VideoControl) player.getControl("VideoControl");
> vc.setDisplayFullScreen(true);
> f.addCommand(new Command("Exit") {
>
> public void actionPerformed(ActionEvent arg0) {
> release();
> exitMIDlet();
> }
> });
>
> f.show();
> } catch (Exception e) {
> }
> }
>
> private void release() {
> if (player != null) {
> try {
> player.stop();
> player.close();
> } catch (MediaException ex) {
> ex.printStackTrace();
> }
> }
> }
>
> public void exitMIDlet() {
> destroyApp(true);
> notifyDestroyed();
> }
>
> public void pauseApp() {
> }
>
> public void destroyApp(boolean unconditional) {
> }
> }
> [Message sent by forum member 'zhenswx' (zhenswx)]
>
> http://forums.java.net/jive/thread.jspa?messageID=289987
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>
>

--
http://www.somatik.be
Microsoft gives you windows, Linux gives you the whole house.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
For additional commands, e-mail: users-help@lwuit.dev.java.net

zhenswx
Offline
Joined: 2008-07-13

Thanks for help.
Is there any solution to this problem?
I want to show my application on the emulator,so I hope to solve it.

setFlashGraphicsBug is not a static method,
so I try "Display.getInstance().setFlashGraphicsBug(false);"
but it doesn't work,the grey area is still there.

Any suggestion? Thanks.

damkea
Offline
Joined: 2008-07-22

Display.getInstance().setFlashGraphicsBug(false) doesn't solve it for the emulator itself.

There isn't really a solution for this problem, except using another emulator than the emulators coming with the Sun Wireless Toolkit.