J2ME - 使用javax.microedition.amms.control.camera.CameraControl;是有可能禁用快门声? [英] J2ME - using javax.microedition.amms.control.camera.CameraControl; is it possible to disable shutter sound?

查看:125
本文介绍了J2ME - 使用javax.microedition.amms.control.camera.CameraControl;是有可能禁用快门声?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的黑莓应用程序,我已经实现了摄像头,并想与我自己来替换默认的快门声。我想我可以通过使用该方法enableShutterFeedback(假),然后打我自己的声音,或者打我的声音相机立即被激活之前沉默的默认摄像头的声音做到这一点。

In my Blackberry app I've implemented the camera and would like to replace the default shutter sound with my own. I figured I could do this by silencing the default camera sound by using the method enableShutterFeedback(false) then playing my own sound, or playing my sound immediately before the camera is activated.

private void initializeCamera()
    {
        try
        {
            // Create a player for the Blackberry's camera
            Player player = Manager.createPlayer( "capture://video" );

            // Set the player to the REALIZED state (see Player javadoc)
            player.realize();

            // Grab the video control and set it to the current display
            _videoControl = (VideoControl)player.getControl( "VideoControl" );

            if (_videoControl != null)
            {
                // Create the video field as a GUI primitive (as opposed to a
                // direct video, which can only be used on platforms with
                // LCDUI support.)
                _videoField = (Field) _videoControl.initDisplayMode (VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");
                _videoControl.setDisplayFullScreen(true);
                _videoControl.setVisible(false);
            }
            cc = (CameraControl)player.getControl("CameraControl");
            cc.enableShutterFeedback(false);
            // Set the player to the STARTED state (see Player javadoc)
            player.start();

        }
        catch(Exception e)
        {
            MyApp.errorDialog("ERROR " + e.getClass() + ":  " + e.getMessage());
        }
    }

这导致空指针异常,但无法弄清楚什么导致它,摄像头的视频不会被显示出来。如果我删除CameraControl code粗体则摄像机的视频显示。任何想法,我应该尝试摆脱快门声音吗?我试图volume control还到位CameraControl的,同样的结果,空指针。

This results in a Null pointer exception but can't figure out what's causing it, the camera's video doesn't get displayed. If I remove the CameraControl code in bold then the camera's video is shown. Any ideas what I should try to get rid of the shutter sound? I tried VolumeControl in place of CameraControl, same results, null pointer.

推荐答案

该CameraControl code给出了NPE,因为 player.getControl 返回null,而它这样做因为字符串参数是不正确的。试试这个:

The CameraControl code gives a NPE because player.getControl returns null, and it does so because the string param is not correct. Try this one:

CameraControl control = (CameraControl) p.getControl("javax.microedition.amms.control.camera.CameraControl");

这篇关于J2ME - 使用javax.microedition.amms.control.camera.CameraControl;是有可能禁用快门声?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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