gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:54:15 26 4
gpt4 key购买 nike

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

这会导致空指针异常,但无法弄清楚是什么原因导致的,摄像头的视频没有显示。如果我删除粗体的 CameraControl 代码,则会显示相机的视频。有什么想法可以消除快门声吗?我尝试用 VolumeControl 代替 CameraControl,结果相同,空指针。

最佳答案

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

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

关于java - J2ME - 使用 javax.microedition.amms.control.camera.CameraControl;是否可以禁用快门声音?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9657619/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com