如何设置多个相机模式flex?

时间:2011-07-19 04:00:31

标签: flash flex actionscript-3 camera

我有一种情况,我必须有一些不同大小的“相机”通过网络流发送,具体取决于它是桌面还是移动连接。以下是我设置的方法:

protected var nearCam:Camera;
protected var nearCamForMobile:Camera;

nearCam = Camera.getCamera();
nearCam.setMode(385,240,10);
nearCam.setQuality(0,0);
//this is the cam I want to display on the near Side to show the user themselves.
near_video.attachCamera(nearCam);


//If a mobile user connects, I want to send them this resolution/aspect ratio of a camera so i'm just setting up this Camera but not showing it anywhere.         
nearCamForMobile = Camera.getCamera();
nearCamForMobile.setMode(480,800,10);
nearCamForMobile.setQuality(0,0);

因此,当移动用户连接时,我只是将连接到网络流的相机交换到移动用户,这样它在手机上看起来不错,而不是全部拉伸。

if(isFarMobile)
{
    sendStream.attachCamera(nearCamForMobile);
}
else
{
    sendStream.attachCamera(nearCam);
}

现在问我的问题......

如果我只做了nearCamForMobile并将其发送到移动通道,它在手机上看起来很棒并且它没有拉伸。但显然它的480x800分辨率在桌面版本上看起来很紧张,这是一个385x240的视频盒。因此,如果我只使用nearCam,它在桌面上看起来很棒,但它在移动设备上看起来很紧张....

所以我很好奇为什么我可以按照上面显示的方式进行两种变换,显示nearCam,然后在需要时将nearCamForMobile等待发送?

您一次只能设置一种相机模式吗?我有什么想法可以做到这一点?在移动版本的设置,所以用户在potrait和它的840x480手机。桌面网站看起来最像是宽屏视频。

最后,我基本上试图弄清楚如何拥有2个具有2种分辨率的相机变速器。在远端是移动客户端的情况下,在近侧显示1并将另一个连接到网络流。 (我知道如何判断远程是否移动,我不担心那部分)

我只需要能够传输一个看起来适合移动客户端的分辨率/宽高比。恰好是与桌面清晰度不同的宽高比。

2 个答案:

答案 0 :(得分:1)

无法完成。请专门从文档中查看此行:

  

“多次调用getCamera()方法引用同一个摄像头   驱动程序。因此,如果您的代码包含类似firstCam的代码:Camera =   getCamera()和secondCam:Camera = getCamera(),firstCam和   secondCam引用相同的摄像头,这是用户的默认值   照相机“。

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Camera.html#getCamera()

换句话说,只要你得到一个,任何后续的get尝试都只会创建另一个指向同一个对象的指针。因此,您有两个带有指向同一对象的指针的变量。在该指针上设置属性会将其设置为两者。

有意义吗?

对不起坏消息:\

答案 1 :(得分:0)

如果您使用的是Flash Builder 4.5,则可以通过调用CameraUI而不是Camera来检查您是否正在访问移动摄像头。您可以通过以下方式编码来检查您拥有的相机类型:

if(CameraUI.isSupported)
{
    //Mobile camera
}
else
{
    //Desktop camera
}

您可以在以下链接中找到更多信息:http://www.flex-tutorial.fr/2010/09/07/air-android-prendre-des-photos-videos-avec-cameraui/

希望这会有所帮助:)

相关问题