打开闪存作为黑莓灯 [英] Turn on Flash as Light on Blackberry

查看:173
本文介绍了打开闪存作为黑莓灯的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新黑莓应用开发和试图使一个简单的应用程序把我的闪光灯作为手电筒。我知道有几个应用程序已经这样做了,但我想尝试一下做我自己。

我已经安装了Eclipse和所有necesary加上得到我的开发环境中运行。我也成功地创建标准储备Hello World应用程序。

不过,我在努力寻找如何做到这一点。我一直在读通过API文档,并开始与 FlashControl VideoControl对玩和 SnapshotControl 。结果
然而这些似乎并没有暴露的方法来做到这一点。

我知道通过视频摄像头,我能够去选择并打开闪光灯上,这正是我想要模仿。

在code,到目前为止,这似乎只是设置相机的闪光灯就迫使我用的是:

 播放器P = javax.microedition.media.Manager.createPlayer(捕获://视频);
p.realize();
p.start();FlashControl flashControl =(FlashControl)p.getControl(javax.microedition.amms.control.camera.FlashControl);
flashControl.setMode(FlashControl.FORCE);


解决方案

相关的闪光灯控制问题已经被我解决了。

根据我使用我最近在应用程序中的闪光控制

摄像头。

下面是code这是我使用的:

 公共摄像头(诠释J)
{
    K =焦耳;
    尝试
    {
        Player播放器= Manager.createPlayer(捕获://视频);
        player.realize();        _videoControl =(VideoControl对)player.getControl(VideoControl对);
        flashControl =新FlashControl()
        {
            公共无效setMode(INT模式)
            {
                // TODO自动生成方法存根
            }            公共布尔isFlashReady()
            {
                // TODO自动生成方法存根
                返回false;
            }            公众诠释[] getSupportedModes()
            {
                // TODO自动生成方法存根
                返回null;
            }            公众诠释获取模式()
            {
                // TODO自动生成方法存根
                返回0;
            }
        };
        flashControl =(FlashControl)播放器
                .getControl(javax.microedition.amms.control.camera.FlashControl);        尝试{            如果(K == 1)
            {
                flashControl.setMode(FlashControl.AUTO);
                Dialog.alert(编程选择自动);
            }
            否则如果(K == 2)
            {
                flashControl.setMode(FlashControl.OFF);
                Dialog.alert(编程选择否);
            }
        }
        赶上(例外五)
        {
            的System.out.println(E);
        }        如果(_videoControl!= NULL)
        {
            _videoField =(场)_videoControl.initDisplayMode(
                    VideoControl.USE_GUI_PRIMITIVE,
                    net.rim.device.api.ui.Field);            // _videoControl.setDisplaySize(330,420);
            // _videoControl.setDisplayLocation(getContentWidth(),
            // getContentHeight());            _videoControl.setVisible(真);            加(_videoField);            捕获=新ButtonField字段(捕捉,Field.FIELD_HCENTER);
            capture.setChangeListener(本);            加(捕捉);
            player.start();        }
    }
    赶上(例外五)
    {
        的System.out.println(E);
    }
}

这个逻辑已经与Pinkesh同时实现为我的同事

在the公司

I am new to BlackBerry application development and trying to make a simple application to turn my flash light on as a torch. I know there are several applications that do this already, but I would like to try do it on my own.

I have installed eclipse and all the necesary add on to get my development environment running. I have also successfully create the stock standard hello world application.

I am however struggling to find out how to do this. I have been reading through the API documentation and started playing with FlashControl, VideoControl and SnapshotControl.
These however don't seem to expose methods to do this.

I know through the video camera I am able to go to options and turn the flash light on and this is exactly what i'm trying to mimic.

The code i have used so far which seems to just set the camera flash to force on is:

Player p = javax.microedition.media.Manager.createPlayer("capture://video");
p.realize();
p.start();

FlashControl flashControl = (FlashControl) p.getControl("javax.microedition.amms.control.camera.FlashControl");
flashControl.setMode(FlashControl.FORCE);

解决方案

the problem relevant to the flash control has been resolved by me

as per i am using the flash control on my recent application on

camera.

Here is the code which i used :

public Camera(int j) 
{
    k = j;
    try 
    {
        Player player = Manager.createPlayer("capture://video");
        player.realize();

        _videoControl = (VideoControl) player.getControl("VideoControl");
        flashControl = new FlashControl() 
        {
            public void setMode(int mode) 
            {
                // TODO Auto-generated method stub
            }

            public boolean isFlashReady() 
            {
                // TODO Auto-generated method stub
                return false;
            }

            public int[] getSupportedModes() 
            {
                // TODO Auto-generated method stub
                return null;
            }

            public int getMode() 
            {
                // TODO Auto-generated method stub
                return 0;
            }
        };
        flashControl = (FlashControl) player
                .getControl("javax.microedition.amms.control.camera.FlashControl");

        try {

            if (k == 1) 
            {
                flashControl.setMode(FlashControl.AUTO);
                Dialog.alert("slect Auto");
            } 
            else if (k == 2) 
            {
                flashControl.setMode(FlashControl.OFF);
                Dialog.alert("slect No");
            }
        } 
        catch (Exception e) 
        {
            System.out.println(e);
        }

        if (_videoControl != null) 
        {
            _videoField = (Field) _videoControl.initDisplayMode(
                    VideoControl.USE_GUI_PRIMITIVE,
                    "net.rim.device.api.ui.Field");

            // _videoControl.setDisplaySize(330, 420);
            // _videoControl.setDisplayLocation(getContentWidth(),
            // getContentHeight());

            _videoControl.setVisible(true);

            add(_videoField);

            capture = new ButtonField("Capture", Field.FIELD_HCENTER);
            capture.setChangeListener(this);

            add(capture);
            player.start();

        }
    } 
    catch (Exception e) 
    {
        System.out.println(e);
    }
}

this logic has been implemented simultaneously with Pinkesh as my colleage

in the comapny

这篇关于打开闪存作为黑莓灯的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆