简体   繁体   English

Flex移动相机+本机扩展

[英]Flex mobile Camera + Native extension

I've already asked this question on Adobe prerelease forum, but they keep silence, so I need your help! 我已经在Adobe发行前论坛上问过这个问题,但他们保持沉默,因此我需要您的帮助!

I need to make an application that should be able to turn ON/OFF flash light on Android device during live video streaming to server. 我需要制作一个应用程序,该应用程序应该能够在向服务器传输实时视频的过程中在Android设备上打开/关闭闪光灯。

So I made and extension. 所以我做了扩展。 Java function is simple: Java函数很简单:

 try{ 
   if (isOn){
     camera = Camera.open();
       Parameters params = camera.getParameters();
       params.setFlashMode(Parameters.FLASH_MODE_TORCH);
       camera.setParameters(params);
     } else {
        camera.release();
     }     
     } catch( Exception e ){
 }

I used HTC desire S with front and rear camera. 我在前后摄像头上使用了HTC DesireS。 When I do streaming from air application (using as3 camera = Camera.getCamera()) and try to use this extension, it doesn't respond at all 当我从空中应用程序进行流式传输(使用as3 camera = Camera.getCamera())并尝试使用此扩展程序时,它根本不响应

So I found workaround: in flash I've changed code to: 所以我找到了解决方法:在Flash中,我将代码更改为:

 camera = null;
 nativeExtension.turnFlashOn(true);
 camera = Camera.getCamera("1");

This code works only when I use rear camera, but i need to pass argument "1" which is actually front camera, but rear camera is used in this case. 该代码仅在使用后置摄像头时有效,但是我需要传递参数“ 1”,该参数实际上是前置摄像头,但是在这种情况下使用后置摄像头。 Anyway - it works fine. 无论如何-它工作正常。

But when I tried to use this application on HTC with only rear camera, I stucked... I cannot use Camera.getCamera("1") because I have only "0" camera, which is rear camera. 但是,当我尝试仅使用后置摄像头在HTC上使用此应用程序时,我就卡住了...我无法使用Camera.getCamera(“ 1”),因为我只有“ 0”摄像头,即后置摄像头。 So when I use this code: 因此,当我使用此代码时:

 camera = null;
 nativeExtension.turnFlashOn(true);
 camera = Camera.getCamera("0");

my image freezes for both sides (Android app and on the other side) and it goes normal when the flash is off 我的图像两面都冻结(Android应用程序和另一面),并且当闪光灯关闭时它恢复正常

I think this is because you still have the camera open in the native extension. 我认为这是因为您仍在本机扩展中打开了相机。 You are only releasing it when you run nativeExtension.turnFlashOn(false) 您仅在运行nativeExtension.turnFlashOn(false)时将其释放

The camera resource can only be held by one process at a time. 摄像机资源一次只能由一个进程保存。 This is why it is freezing. 这就是为什么它冻结。 I suspec if you look at your system logs (logcat) you will see errors like "Unable to connect to camera" When your flash is off, you have run camera.release() so it isn't being held and AS can acquire it. 我怀疑如果您查看系统日志(logcat),将会看到诸如“无法连接到相机”之类的错误消息。当闪光灯关闭时,您已经运行了camera.release(),因此它没有被保存,AS可以获取它。

I am not sure whats going down in AS where your requesting the front camera but using back. 我不确定您要求前置摄像头但使用后置摄像头的AS中发生了什么。 You aren't very clear. 你不是很清楚。 Either way, dont do this because your desired result can not be done, because it would require two processes holding the camera resource at the same time. 无论哪种方式,都不要这样做,因为无法实现所需的结果,因为这将需要两个进程同时保存摄像机资源。

Why dont you do your streaming from your native extension? 您为什么不从本机扩展中进行流式传输? That way you can use the camera and flash at the same time, and performance may be alot better since it is running natively. 这样,您可以同时使用相机和闪光灯,由于它是本地运行的,因此性能可能会更好。 Flex's support for the Camera and recording video is really poor. Flex对相机和录制视频的支持确实很差。 I was going to use it and eventually decided to move all my camera processes to a NE. 我打算使用它,最终决定将我所有的摄像头过程移至NE。

Hope this helps 希望这可以帮助

If your device has 0, 1, 2 cameras installed try this logic 如果您的设备安装了0、1、2个摄像头,请尝试以下逻辑

 camera = null;
 nativeExtension.turnFlashOn(true);
// get front camera
camera = Camera.getCamera("1");
// if no front cam try back
if (camera == null)
 camera = Camera.getCamera("0");
// if no cams try default cam
if (camera == null)
 camera = Camera.getCamera();
else {
  trace("Mobile device has no camera!");
}

This code works on device with zero, 0, or 2 cams 此代码适用于具有零个,0个或2个凸轮的设备

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将Camera类与Flex Mobile Framework和Android一起使用 - Using the Camera class with Flex Mobile Framework and Android Flex应用程序与本机移动应用程序之间的Flex移动通信 - Flex mobile communcation between flex apps vs native mobile apps flex android动作脚本原生扩展 - flex android action script native extension 带有适用于Android的Dropbox API的Flex本机扩展 - Flex Native Extension with Dropbox API for Android 原生Android VS Flex移动文件系统速度 - Native Android VS Flex mobile filesystem speed 将指南叠加层添加到Flex视频组件(移动相机)。 - Add a guide overlay to a flex video component (Mobile Camera). 如何使用手机摄像头在 React Native 中拍照并获取数据 - How to take a picture and get the data in React Native with the mobile camera 如何在Adobe Native Mobile的Android Native Extension中包含额外的Jar - How to include additional Jar in Android Native Extension for Adobe Air Mobile 从Flex Mobile中的默认相机应用程序拍摄照片后,如何上传照片? - how can i upload a photo when it is taken from the default camera app in flex mobile? 从Android的本机扩展加载地图活动时,如何使Flex控件可见? - How to make flex control visible while loading map activity from the native extension for android?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM