J2ME – 使用javax.microedition.amms.control.camera.CameraControl; 是否可以禁用快门声音?

在我的Blackberry应用程序中,我已经实现了相机,并希望用我自己的替换默认的快门声音。 我想我可以通过使用方法enableShutterFeedback(false)然后播放我自己的声音来静音默认的摄像机声音,或者在激活摄像机之前立即播放我的声音。

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()); } } 

这会导致Null指针exception但无法弄清楚导致它的原因,相机的video无法显示。 如果我以粗体移除CameraControl代码,则会显示相机的video。 有什么想法我应该试图摆脱快门声音? 我尝试用VolumeControl代替CameraControl,结果相同,空指针。

CameraControl代码给出一个NPE,因为player.getControl返回null,并且它这样做是因为字符串参数不正确。 试试这个:

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