If you’re using Flash then you can use the FLVPlayer component to stream your video very easily just by passing in the full RTMP url. This may look something like this rtmp://streamingserviceprovider.com/application/instance/folder/videofile.flv.
In Flex you have the VideoDisplay component which is not as good as the FLVPlayer component and has a few bugs which I wont go into here. Incidentally, if you want a good Flex video component with playback controls and skins then go see the charming Mike jones over here. The VideoDisplay component has a bug that means sometimes you can’t get the video to scale up to fit the complete with & height of the container. You can go and override some methods in the component to fix this but I’d decided to build a simple, lightweight Video display object based on the flash.media.Video class. My video is being used as a background and doesn’t need any user interaction; but it does need to scale up to fit the rect and also be smoothed … you know the score.
This is quite straightforward to do when playing out a progressive video file. You connect the NetConnection object, open a NetStream and pass in the URL as an argument and then you attach the NetStream to the Video object. You don’t need me to post code for this here; just look at the flash.media.Video class reference.
What isn’t so clear is how to link to a video stream from a streaming server. If you dig around the AS3 class reference files you’ll find the information you need within the NetConnection and NetStream classes. But here’s the lowdown very quickly.
When you connect your NetConnection object instead of null as your argument you need to pass in the Streaming server url with the application name, instance and folder structure. Then you pass in the filename to the NetStream object BUT don’t include the file extension. Like so:
-
var ns:NetStream = new NetStream();
-
ns.play("videofile");
Just to be clear for all the people scanning the code … DON’T PUT THE FILE EXTENSION IN AND PUT THE PATH IN THE NETCONNECTION OBJECT!
That should clear up any confusion.


May 20th, 2009 at 4:44 am
Hello.. sorry for mi poor english =P
this code don't work… and my old code was similar =S
Help me please !!
September 22nd, 2009 at 11:40 am
Thanks to author.
December 8th, 2009 at 3:35 pm
I noticed a change to the SDK in 3.4 which means you can’t put the url in the constructor. You need to use the connect method like so nc.connect(”rtmp://streamingserviceprovider.com/application/instance/folder/”);