【发布时间】:2011-03-30 22:20:24
【问题描述】:
这是我的问题:我想创建一个带有相机的特定组件和一个代表覆盖 VideoControl 视图的目标的图像。
首先,我想在带有 TitleBar 的 MainScreen 中显示相机。
这是我的代码:
public class ScanScreen extends MainScreen {
private ScanScreen()
{
super();
this.vfm = new VerticalFieldManager(Field.FIELD_VCENTER);
this.controller = new ScanController(this);
//Initialize the player.
try
{
this.player = javax.microedition.media.Manager.createPlayer("capture://video?encoding=jpeg&width=1024&height=768");
this.player.realize();
this.player.prefetch();
this.videoControl = (VideoControl) this.player.getControl("VideoControl");
if(this.videoControl != null)
{
// Initialize the field where the content of the camera shall be displayed.
Field videoField = (Field) this.videoControl.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");
// Display the video control.
this.videoControl.setDisplayFullScreen(true);
this.videoControl.setVisible(true);
// Start the player.
this.player.start();
// Add the video field to the main screen.
if(videoField != null)
{
this.vfm.add(videoField);
}
else
{
LabelField sorry = new LabelField("Sorry, we cannot use camera right now.");
this.vfm.add(sorry);
}
}
}
catch(Exception e)
{
Dialog.alert(e.toString());
}
// TODO : the camera is hiding the title bar
this.setTitle("Title");
this.add(this.vfm);
}
}
第一个问题是 VideoContol 的视图隐藏了我的标题栏。我该如何解决?
第二件事:我有一个特定的矩形图像,它代表一个透明的目标,我想在 VideoControl 的视图上显示它。
我首先尝试创建一个扩展 Field 的新类,该类返回该图像的尺寸,并使图像显示在paint方法中(该类是“mypackage.CameraField”)。然后我尝试在 initDisplayMode 中用我的新类“mypackage.CameraField”的名称实例化我的 VideoField;但创建的 videoField 为空。
那么,是否有解决方案来创建这种行为?我正在考虑“多媒体”文件夹中的本机应用程序“摄像机”,它在屏幕的特定区域显示 VideoControl。
谢谢。
【问题讨论】:
标签: blackberry java-me camera blackberry-jde