在我的黑莓应用程序中,我已经实现了相机,并希望用我自己的声音替换默认的快门声音。我想我可以通过使用方法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());
}
}
这会导致空指针异常,但无法找出原因,相机的视频不会显示。如果我删除粗体的 CameraControl 代码,则会显示相机的视频。有什么想法我应该尝试消除快门声音吗?我尝试用 VolumeControl 代替 CameraControl,结果相同,空指针。
CameraControl 代码给出了 NPE,因为player.getControl
返回 null,这是因为字符串参数不正确。试试这个:
CameraControl control = (CameraControl) p.getControl("javax.microedition.amms.control.camera.CameraControl");
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)