使用 VideoControl 在黑莓应用程序中捕获图片仅适用于模拟器,不适用于设备
这只是部分代码,因为它的其他部分是分散的,但在黑莓曲线模拟器上,这会向管理器添加一个 VideoControl,并与实际捕获图片的另一个按钮一起显示良好。然而,当我在实际的 Blackberry curve(我认为是版本 6)上运行它时,它不会在屏幕上显示它。
try
{
_p = javax.microedition.media.Manager.createPlayer("capture://video?encoding=jpeg&width=1024&height=768");
_p.realize();
_videoControl = (VideoControl) _p.getControl("VideoControl");
if (_videoControl != null)
{
videoField = (Field) _videoControl.initDisplayMode (VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");
// _videoControl.setDisplayFullScreen(true);
_videoControl.setVisible(true);
// EnhancedFocusControl efc = (EnhancedFocusControl)p.getControl("net.rim.device.api.amms.control.camera.EnhancedFocusControl");
// efc.startAutoFocus();
_p.start();
if(videoField != null)
{
add(videoField);
}
}
}
catch(Exception e)
{
Dialog.alert(e.toString());
}
This is only some of the code because other parts of it are spread out but on the simulator for blackberry curve this adds a VideoControl to the manager and shows up fine with another button that actually captures the picture. However, when I run this on an actual Blackberry curve (version 6 I think) it doesn't display this on the screen.
try
{
_p = javax.microedition.media.Manager.createPlayer("capture://video?encoding=jpeg&width=1024&height=768");
_p.realize();
_videoControl = (VideoControl) _p.getControl("VideoControl");
if (_videoControl != null)
{
videoField = (Field) _videoControl.initDisplayMode (VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");
// _videoControl.setDisplayFullScreen(true);
_videoControl.setVisible(true);
// EnhancedFocusControl efc = (EnhancedFocusControl)p.getControl("net.rim.device.api.amms.control.camera.EnhancedFocusControl");
// efc.startAutoFocus();
_p.start();
if(videoField != null)
{
add(videoField);
}
}
}
catch(Exception e)
{
Dialog.alert(e.toString());
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据我的经验,您使用的图像拍摄方式似乎非常不可靠(它仅在有限数量的设备上运行良好),因此我停止使用它。请改用本机相机应用程序 - 它在所有设备上都能正常工作。
In my experience the way of image taking you use has appeared very unreliable (it worked fine only on a limited number of devices), so I stopped using it. Use native Camera app instead - it works fine on all devices.
很多时候,当事情在模拟器上运行而不是在设备上运行时,它的权限相关,你检查过ApplicationPermissionsManager吗?
警告一下,从 OS4.5 到 6,许多内容已被弃用,因此请务必检查您是否拥有正在使用的模型的正确权限。
例如,我认为
ApplicationPermissions.PERMISSION_SCREEN_CAPTURE
在 4.6 中已被弃用。A lot of the time when things work on the emulator but not device it's permissions related, have you checked ApplicationPermissionsManager?
Word of warning, from OS4.5 to 6 a lot of stuff has been deprecated so be sure you check you have the right permissions for the models you are working with.
e.g.
ApplicationPermissions.PERMISSION_SCREEN_CAPTURE
was deprecated in 4.6 I think.