<p>I'm wondering how to use a VideoDisplay object (defined in MXML) to display video streamed from FMS via a NetStream.</p>

<p>The <a href="http://livedocs.adobe.com/flex/3/langref/mx/controls/VideoDisplay.html" rel="noreferrer">Flex3 docs</a> suggest this is possible:</p>

<blockquote>
  <p>The Video Display ... supports progressive download over HTTP, streaming from the Flash Media Server, and streaming from a Camera object.</p>
</blockquote>

<p>However, later in the docs all I can see is an attachCamera() method.  There doesn't appear to be an attachStream() method like the old Video object has.</p>

<p>It looks like you can play a fixed file served over HTML by using the source property, but I don't see anything about how to attach a NetStream.</p>

<p>The old <a href="http://livedocs.adobe.com/flex/3/langref/flash/media/Video.html" rel="noreferrer">Video</a> object still seems to exist, though it's not based on UIComponent and doesn't appear to be usable in MXML.</p>

<p>I found <a href="http://blog.flexexamples.com/2008/03/01/displaying-a-video-in-flex-using-the-netconnection-netstream-and-video-classes/" rel="noreferrer">this blog post</a> that shows how to do it with a regular Video object, but I'd much prefer to use VideoDisplay (or something else that can be put directly in the MXML).</p>

[{'answer_id': 42684, 'author': 'Artem Tikhomirov', 'author_id': 2313, 'author_profile': 'https://Stackoverflow.com/users/2313', 'pm_score': 4, 'selected': True, 'text': '<p>Unfortunately you can attachNetStream() only on Video object. So you are doomed to use em if you want to get data from FMS.</p>\n\n<p>By the way attachCamera() method <strong>publishes</strong> local camera video to the server so be careful ;)</p>\n'}, {'answer_id': 290890, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 2, 'selected': False, 'text': '<p>it works.</p>\n\n<p>mx:VideoDisplay live="true" autoPlay="true" source="rtmp://server.com/appname/streamname" /></p>\n\n<p>that will give you live video through a videodisplay... problem is it won\'t use an existing netconnection object, it creates it\'s own... which is what I\'m trying to find a work around for.</p>\n'}, {'answer_id': 762430, 'author': 'Ken Smith', 'author_id': 68231, 'author_profile': 'https://Stackoverflow.com/users/68231', 'pm_score': 2, 'selected': False, 'text': "<p>I've seen sample code where something like this works:</p>\n\n<pre><code>// Connect to the video stream in question.\nvar stream:NetStream = new NetStream( chatNC );\nstream.addEventListener( NetStatusEvent.NET_STATUS, handleStreamStatus );\nstream.addEventListener( IOErrorEvent.IO_ERROR, handleIOError );\n\n// Build the video player on the UI.\nvar video:Video = new Video(246, 189);\nvar uiComp:UIComponent = new UIComponent();\nuiComp.addChild( video );\nuiComp.width = 246;\nuiComp.height = 189;\nstream.play( streamName );\nvideo.attachNetStream( stream );\nvideo.smoothing = true;\nvideo.width = 246;\nvideo.height = 189;\nview.videoPlayerPanel.removeAllChildren();\nview.videoPlayerPanel.addChild( uiComp );\n</code></pre>\n\n<p>But I can't actually get it to work myself.  I'll post here later if I can figure it out.</p>\n"}, {'answer_id': 3117046, 'author': 'Cosma Colanicchia', 'author_id': 11867, 'author_profile': 'https://Stackoverflow.com/users/11867', 'pm_score': 4, 'selected': False, 'text': '<p><code>VideoDisplay</code> is a wrapper on <code>VideoPlayer</code>, which in turn <em>is</em> a <code>Video</code> subclass. Unfortunately, the wrapper prevents you from attaching an existing NetStream to the Video object.</p>\n\n<p>However, a reference to that component is held with in the <code>mx_internal</code> namespace, so the following should do the trick:</p>\n\n<pre><code>videoDisplay.mx_internal::videoPlayer.attachNetStream(incomingStream);\nvideoDisplay.mx_internal::videoPlayer.visible = true;\n</code></pre>\n\n<p>(you need to import the <code>mx.core.mx_internal</code> namespace)</p>\n'}, {'answer_id': 3489354, 'author': 'Alexander Farber', 'author_id': 165071, 'author_profile': 'https://Stackoverflow.com/users/165071', 'pm_score': 2, 'selected': False, 'text': '<p>Here a link to example on how to use video:\n<a href="http://blog.flexexamples.com/2008/03/01/displaying-a-video-in-flex-using-the-netconnection-netstream-and-video-classes/" rel="nofollow noreferrer">http://blog.flexexamples.com/2008/03/01/displaying-a-video-in-flex-using-the-netconnection-netstream-and-video-classes/</a></p>\n\n<pre><code>&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"\n    layout="vertical"\n    verticalAlign="middle"\n    backgroundColor="white"\n    creationComplete="init();"&gt;\n\n&lt;mx:Script&gt;\n&lt;![CDATA[\n    import mx.utils.ObjectUtil;\n\n    private var nc:NetConnection;\n    private var ns:NetStream;\n    private var video:Video;\n    private var meta:Object;\n\n    private function init():void {\n    var nsClient:Object = {};\n    nsClient.onMetaData = ns_onMetaData;\n    nsClient.onCuePoint = ns_onCuePoint;\n\n    nc = new NetConnection();\n    nc.connect(null);\n\n    ns = new NetStream(nc);\n    ns.play("http://www.helpexamples.com/flash/video/cuepoints.flv");\n    ns.client = nsClient;\n\n    video = new Video();\n    video.attachNetStream(ns);\n    uic.addChild(video);\n    }\n\n    private function ns_onMetaData(item:Object):void {\n    trace("meta");\n    meta = item;\n    // Resize Video object to same size as meta data.\n    video.width = item.width;\n    video.height = item.height;\n    // Resize UIComponent to same size as Video object.\n    uic.width = video.width;\n    uic.height = video.height;\n    panel.title = "framerate: " + item.framerate;\n    panel.visible = true;\n    trace(ObjectUtil.toString(item));\n    }\n\n    private function ns_onCuePoint(item:Object):void {\n    trace("cue");\n    }\n]]&gt;\n&lt;/mx:Script&gt;\n\n&lt;mx:Panel id="panel" visible="false"&gt;\n    &lt;mx:UIComponent id="uic" /&gt;\n    &lt;mx:ControlBar&gt;\n    &lt;mx:Button label="Play/Pause" click="ns.togglePause();" /&gt;\n    &lt;mx:Button label="Rewind" click="ns.seek(0); ns.pause();" /&gt;\n    &lt;/mx:ControlBar&gt;\n&lt;/mx:Panel&gt;\n&lt;/mx:Application&gt;\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/42333', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1409/']