lwuit 视频组件永不停歇

发布于 2024-12-10 20:14:52 字数 3227 浏览 0 评论 0原文

我正在使用 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.

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼眸印温柔 2024-12-17 20:14:52

这是因为您的视频组件没有正确停止。
尝试添加:

VideoComponent vc;
Player player;
vc = VideoComponent.createVideoPeer("http://localhost/md.3gp");
player = (Player) vc.getNativePeer();
player.realize();
vc.start();

并在操作侦听器中:

player.stop();
vc.stop();
player.close();
loginform();

This is because your video component is not stopping correctly.
Try adding:

VideoComponent vc;
Player player;
vc = VideoComponent.createVideoPeer("http://localhost/md.3gp");
player = (Player) vc.getNativePeer();
player.realize();
vc.start();

and in action listener:

player.stop();
vc.stop();
player.close();
loginform();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文