J2ME - using javax.microedition.amms.control.camera.CameraControl; can I turn off the shutter sound?

In my Blackberry app, I implemented a camera and would like to replace the default shutter sound with my own. I decided that I could do this by turning off the default camera sound using the enableShutterFeedback (false) method, then playing my own sound or playing the sound right before the camera was activated.

private void initializeCamera() { try { // Create a player for the Blackberry 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()); } } 

This leads to a Null pointer exception, but cannot figure out what causes it; video from the camera is not displayed. If I delete the CameraControl code in bold, a video of the camera will appear. Any ideas that I should try to get rid of the shutter sound? I tried VolumeControl instead of CameraControl, same results, null pointer.

+3
source share
1 answer

The CameraControl code gives NPE because player.getControl returns null, and it does because the string parameter is incorrect. Try the following:

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

Source: https://habr.com/ru/post/1483965/


All Articles