如何创建包含 VideoControl 和图像的自定义字段?

发布于 2024-10-26 22:21:30 字数 2200 浏览 2 评论 0原文

这是我的问题:我想创建一个带有摄像头的特定组件和一个代表覆盖 VideoControl 视图的目标的图像。

首先,我想在带有标题栏的主屏幕中显示相机。

这是我的代码:

 public class ScanScreen extends MainScreen {
private ScanScreen() 
    {
        super();

        this.vfm = new VerticalFieldManager(Field.FIELD_VCENTER);

        this.controller = new ScanController(this);
        //Initialize the player.
        try
        {
            this.player = javax.microedition.media.Manager.createPlayer("capture://video?encoding=jpeg&width=1024&height=768");
            this.player.realize();
            this.player.prefetch();
            this.videoControl = (VideoControl) this.player.getControl("VideoControl");

            if(this.videoControl != null)
            {
                // Initialize the field where the content of the camera shall be displayed.
                Field videoField = (Field) this.videoControl.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");

                // Display the video control.
                this.videoControl.setDisplayFullScreen(true);
                this.videoControl.setVisible(true);

                // Start the player.
                this.player.start();

                // Add the video field to the main screen.
                if(videoField != null)
                {
                    this.vfm.add(videoField);
                }
                else
                {
                    LabelField sorry = new LabelField("Sorry, we cannot use camera right now.");
                    this.vfm.add(sorry);
                }
            }
        }
        catch(Exception e)
        {
            Dialog.alert(e.toString());
        }

        // TODO : the camera is hiding the title bar
        this.setTitle("Title");
        this.add(this.vfm);
    }
}

第一个问题是 VideoContol 的视图隐藏了我的标题栏。我该如何解决这个问题?

第二件事:我有一个特定的矩形图像,代表一个具有透明度的目标,我想将其显示在 VideoControl 的视图上。

我首先尝试创建一个新类,扩展 Field 返回该图像的尺寸,并使图像显示在 Paint 方法中(此类为“mypackage.CameraField”)。然后我尝试在 initDisplayMode 中使用新类“mypackage.CameraField”的名称实例化我的 VideoField ;但创建的 videoField 为空。

那么,有没有办法来创造这种行为呢?我正在考虑“多媒体”文件夹中的本机应用程序“摄像机”,它在屏幕的特定区域显示视频控件。

谢谢。

Here is my problem : I would like to create a specific component with the camera and an image representing a target overlaying the VideoControl's view.

First I would like to display the camera in a MainScreen with a TitleBar.

Here is my code :

 public class ScanScreen extends MainScreen {
private ScanScreen() 
    {
        super();

        this.vfm = new VerticalFieldManager(Field.FIELD_VCENTER);

        this.controller = new ScanController(this);
        //Initialize the player.
        try
        {
            this.player = javax.microedition.media.Manager.createPlayer("capture://video?encoding=jpeg&width=1024&height=768");
            this.player.realize();
            this.player.prefetch();
            this.videoControl = (VideoControl) this.player.getControl("VideoControl");

            if(this.videoControl != null)
            {
                // Initialize the field where the content of the camera shall be displayed.
                Field videoField = (Field) this.videoControl.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");

                // Display the video control.
                this.videoControl.setDisplayFullScreen(true);
                this.videoControl.setVisible(true);

                // Start the player.
                this.player.start();

                // Add the video field to the main screen.
                if(videoField != null)
                {
                    this.vfm.add(videoField);
                }
                else
                {
                    LabelField sorry = new LabelField("Sorry, we cannot use camera right now.");
                    this.vfm.add(sorry);
                }
            }
        }
        catch(Exception e)
        {
            Dialog.alert(e.toString());
        }

        // TODO : the camera is hiding the title bar
        this.setTitle("Title");
        this.add(this.vfm);
    }
}

The first problem is that the view of the VideoContol is hiding my title bar. How can I fix that ?

The second thing : I have a specific rectangular image representing a target with transparency which I would like to displaying over the view of the VideoControl.

I first tried to create a new class extending Field returning the dimensions of this image and make the image displayed in the paint method (this class is "mypackage.CameraField"). Then I tried to instantiate my VideoField with the name of my new class "mypackage.CameraField" in the initDisplayMode ; but the created videoField is null.

So, is there a solution to create that kind of behaviour ? I am thinking about the native application "Video Camera" in the "Multimedia" folder that displays a VideoControl in a specific area of the screen.

Thank you.

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

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

发布评论

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

评论(1

來不及說愛妳 2024-11-02 22:21:30

好吧,看来不可能以任何方式自定义 VideoControl。我们必须全屏使用它,并且不能在上面显示任何内容。

Ok, it seems that is not possible to customize the VideoControl in any way. We must use it in fullscreen and cannot display anything on it.

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