我正在使用 lwuit videocomponent 播放视频。
import com.sun.lwuit.Button;
import com.sun.lwuit.Display;
import com.sun.lwuit.Font;
import com.sun.lwuit.Form;
import com.sun.lwuit.Image;
import com.sun.lwuit.VideoComponent;
import com.sun.lwuit.animations.CommonTransitions;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;
import com.sun.lwuit.plaf.Border;
import com.sun.lwuit.table.TableLayout;
import javax.microedition.midlet.*;
public class vtestMidlet extends MIDlet implements ActionListener{
private Image back;
public void startApp() {
Display.init(this);
loginform();
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
void loginform()
{
Form login=new Form();
Button save;
save=new Button("Save");
login.addComponent(save);
login.getSelectedStyle().setBgColor(0xff0000);
login.getUnselectedStyle().setBgColor(0xff0000);
save.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
videoform();
}
});
login.setTransitionOutAnimator(CommonTransitions.createSlide(CommonTransitions.SLIDE_HORIZONTAL, false, 200));
login.show();
}
void videoform()
{
final Form videoplayer;
final VideoComponent vc;
Button home;
try{
videoplayer=new Form();
TableLayout layout2 = new TableLayout(10,1);
videoplayer.setLayout(layout2);
vc = VideoComponent.createVideoPeer("http://localhost/md.3gp");
home=new Button("Home");
vc.start();
videoplayer.getUnselectedStyle().setBgImage(back);
videoplayer.getSelectedStyle().setBgImage(back);
home.getUnselectedStyle().setBgColor(0x4673aa);
home.getSelectedStyle().setBgColor(0x4673aa);
home.getUnselectedStyle().setFont(Font.createSystemFont(Font.FACE_PROPORTIONAL,Font.STYLE_PLAIN, Font.SIZE_MEDIUM));
home.getSelectedStyle().setFont(Font.createSystemFont(Font.FACE_PROPORTIONAL,Font.STYLE_BOLD, Font.SIZE_MEDIUM));
home.getUnselectedStyle().setFgColor(0xffffff);
home.getSelectedStyle().setFgColor(0xffffff);
home.getSelectedStyle().setBorder(Border.createEmpty());
home.getUnselectedStyle().setBorder(Border.createEmpty());
home.getSelectedStyle().setPadding(3, 3, 6, 6);
home.getUnselectedStyle().setPadding(3, 3, 6, 6);
videoplayer.addComponent(vc);
videoplayer.addComponent(home);
videoplayer.setTransitionOutAnimator(CommonTransitions.createSlide(CommonTransitions.SLIDE_HORIZONTAL, false, 200));
home.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
vc.stop();
loginform();
}
});
videoplayer.show();
}
catch(Exception e)
{
e.printStackTrace();
}
}
public void actionPerformed(ActionEvent arg0) {
}
}
我的问题是,当从显示视频(即 videoform)的表单切换回另一个表单(即登录表单)时,视频会在登录表单的顶部播放。找到下面的屏幕截图。