如何将相机附加到 Spark.components.VideoDisplay

发布于 2024-10-02 05:13:49 字数 587 浏览 0 评论 0原文

我正在使用 Flash Builder 并创建了一个 Spark 应用程序 Flex 项目,该项目将从本地摄像机流式传输视频。如果我使用 mx.controls.VideoDisplay ;没有问题,因为它有 attachCamera(camera) 方法。但 Spark 的 VideoDisplay 组件没有该方法。我知道我可以在 Spark 应用程序中使用 mx 控件,但我想知道:

  • spark.components.VideoDisplaymx.controls.VideoDisplay 之间的真正区别是什么?
  • 如何将摄像头连接到 spark.components.VideoDisplay
  • 如果我使用 Spark 有什么优势(因为它比 mx 库更新)?

谢谢。

编辑:在文档中提到:“从 Flex 4.0 开始,Adobe 建议您使用 Spark.components.VideoPlayer 类作为此类的替代品。(mx.controls.VideoDisplay )

I'm using Flash Builder and created a spark-application Flex project that will stream video from the local camera. If I use mx.controls.VideoDisplay; there is no problem since it has attachCamera(camera) method. But Spark's VideoDisplay component does not have that method. I know I can use mx controls inside a Spark app but I want to know:

  • What is the real difference between spark.components.VideoDisplay and mx.controls.VideoDisplay?
  • How do I attach camera to spark.components.VideoDisplay?
  • Is there any advantages if I go with spark (since it's newer to mx library)?

thanks.

EDIT: In the documentation this is mentioned: "Starting with Flex 4.0, Adobe recommends that you use the spark.components.VideoPlayer class as an alternative to this class. (mx.controls.VideoDisplay)"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

夏雨凉 2024-10-09 05:13:49

以下是使其发挥作用的具体细节:

import mx.events.FlexEvent;

import org.osmf.net.StreamType;

import spark.components.mediaClasses.DynamicStreamingVideoItem;
import spark.components.mediaClasses.DynamicStreamingVideoSource;

private var _cam:DynamicStreamingVideoSource =  new DynamicStreamingVideoSource();
private var _dynVideoSource:DynamicStreamingVideoSource;

protected function application1_creationCompleteHandler(event:FlexEvent):void
{

    _dynVideoSource=new DynamicStreamingVideoSource();

    var videoItems:Vector.<DynamicStreamingVideoItem>;
    videoItems=new Vector.<DynamicStreamingVideoItem>();
    videoItems[0]=new DynamicStreamingVideoItem();

    _dynVideoSource.host= "";
    _dynVideoSource.streamType=StreamType.LIVE;
    _dynVideoSource.streamItems=videoItems;

    mycam.source=_dynVideoSource;

    var cam:Camera = Camera.getCamera(); //Camera.names[0]);
    cam.setMode(640, 480, 15);
    cam.setQuality(0, 80);
    mycam.videoObject.attachCamera(cam); 
}

Here are the specifics to get this working:

import mx.events.FlexEvent;

import org.osmf.net.StreamType;

import spark.components.mediaClasses.DynamicStreamingVideoItem;
import spark.components.mediaClasses.DynamicStreamingVideoSource;

private var _cam:DynamicStreamingVideoSource =  new DynamicStreamingVideoSource();
private var _dynVideoSource:DynamicStreamingVideoSource;

protected function application1_creationCompleteHandler(event:FlexEvent):void
{

    _dynVideoSource=new DynamicStreamingVideoSource();

    var videoItems:Vector.<DynamicStreamingVideoItem>;
    videoItems=new Vector.<DynamicStreamingVideoItem>();
    videoItems[0]=new DynamicStreamingVideoItem();

    _dynVideoSource.host= "";
    _dynVideoSource.streamType=StreamType.LIVE;
    _dynVideoSource.streamItems=videoItems;

    mycam.source=_dynVideoSource;

    var cam:Camera = Camera.getCamera(); //Camera.names[0]);
    cam.setMode(640, 480, 15);
    cam.setQuality(0, 80);
    mycam.videoObject.attachCamera(cam); 
}
坏尐絯℡ 2024-10-09 05:13:49

直接地说,答案是您无法将摄像头连接到 Spark VideoDisplay。对不起。我也试图实现这一点,但我必须默认使用 mx VideoDisplay 并且使用它没有任何问题:)

Spark 较新,我也更喜欢尽可能使用它,但在这个情况下,您只需要使用 MX 控件即可。它发生了。

Straight up, the answer is that you can't attach a camera to the Spark VideoDisplay. Sorry. I was trying to make this happen too, but I had to default to the mx VideoDisplay and there's nothing wrong with using it :)

Spark is newer and I prefer to use it whenever possible too, but in this case, you just need to use the MX control. It happens.

鸩远一方 2024-10-09 05:13:49

我尝试将相机附加到 videoDisplay.videoObject - 但 videoObject 始终为 null,这会引发错误。

为了解决这个问题,我创建了一个虚拟 DynamicStreamingVideoObject 并将其作为源传递

_cam = new DynamicStreamingVideoSource();

<s:VideoDisplay id="mycam" source="_cam" />

,然后在应用程序的creationComplete 处理程序中我这样做了,

var cam:Camera = Camera.getCamera();
mycam.videoObject.attachCamera(cam); 

这解决了问题。

I tried to attach the camera to videoDisplay.videoObject - but the videoObject was always null, which throws an error.

To resolve that I created a dummy DynamicStreamingVideoObject and passed it as the source

_cam = new DynamicStreamingVideoSource();

<s:VideoDisplay id="mycam" source="_cam" />

then, in the creationComplete handler of the application i did this

var cam:Camera = Camera.getCamera();
mycam.videoObject.attachCamera(cam); 

this resolved the issue.

简美 2024-10-09 05:13:49

一直在寻找解决方案,并找到了以下内容,

var cam:Camera = Camera.getCamera(); 
cam.setMode(320, 240, 15);
cam.setQuality(0, 0);
var myCam:Video = new Video(320,240);
myCam.attachCamera(cam);
myVideo.addChild(myCam);

谢谢

Been looking for a solution to this and found the below

var cam:Camera = Camera.getCamera(); 
cam.setMode(320, 240, 15);
cam.setQuality(0, 0);
var myCam:Video = new Video(320,240);
myCam.attachCamera(cam);
myVideo.addChild(myCam);

thanks

孤独患者 2024-10-09 05:13:49

更短的解决方法:

<s:VideoDisplay id="camVideoDisplay"
                source="dummy"
                autoPlay="false"
                autoDisplayFirstFrame="false"/>

在这种情况下,可以将 Video 对象引用为 camVideoDisplay.videoObject,例如:

camVideoDisplay.videoObject.attachCamera( .. );

Shorter workaround:

<s:VideoDisplay id="camVideoDisplay"
                source="dummy"
                autoPlay="false"
                autoDisplayFirstFrame="false"/>

In this case, the Video object can be then referenced as camVideoDisplay.videoObject, e.g.:

camVideoDisplay.videoObject.attachCamera( .. );
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文