lwuit 视频组件永不停歇
我正在使用 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 )切换回另一个表单(即 loginform )时,视频在登录表单之上播放。找到下面的屏幕截图。
i'm using lwuit videocomponent to play video.
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) {
}
}
My problem is when switch back to another Form (i.e loginform) from Form that displays video (i.e videoform ) , the video plays on top of the loginform. find the screenshot below.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是因为您的视频组件没有正确停止。
尝试添加:
并在操作侦听器中:
This is because your video component is not stopping correctly.
Try adding:
and in action listener: