Rap*_*981 3 java blackberry java-me
在我的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());
}
}
Run Code Online (Sandbox Code Playgroud)
这会导致Null指针异常,但无法弄清楚导致它的原因,相机的视频无法显示.如果我以粗体移除CameraControl代码,则会显示相机的视频.我应该尝试摆脱快门声音的任何想法?我尝试用VolumeControl代替CameraControl,结果相同,空指针.
CameraControl代码给出一个NPE,因为player.getControl返回null,并且它是这样做的,因为字符串参数不正确.试试这个:
CameraControl control = (CameraControl) p.getControl("javax.microedition.amms.control.camera.CameraControl");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
903 次 |
| 最近记录: |