RTMP is the protocol used by Adobe’s Flash Media Server to stream content into flash. Most of the help documentation doesn’t touch much on this method of connection and is limited to sources not easily available to users.
This article should be used by those with an understanding of video playback using actionscript 3. If that isn’t you, please read this article before continuing.
1.) In order to use the RTMP protocol, you will need to install and run a version of Adobe Flash Media Server. Adobe has released a free developer version the limits you to 10 connections. That will be MORE than enough to do some basic development. Please make sure you are running or have access to a Flash Media Server before continuing to the next step.
1.) (B) If you are having trouble installing or setting up an app, please read this article.
2.) Now that you have access to a Flash Media Server, we will start with some basic code that should look familiar if you have worked with actionscript and video before. For this step, you will need to know the URI for the server. If you installed Flash Media server on the machine you are running on, you can use “localhost” for the URI. We will be using the “vod” app that comes pre-installed on the server for this example.
var nc:NetConnection = new NetConnection(); nc.connect("rtmp://YOUR_SERVER_URI/vod/");
If we were loading an flv file without streaming, you would have passed null to the connect() method instead.
3.) The only thing left is to load the stream, instead of loading an FLV video from a URL. This is actually much easier than you think. Instead of passing a URLRequest to the NetStream.play() method, you would instead pass the name of the stream you wish to play from within your app (this is the name of the FLV file on the server, but without the .FLV extension). To playback an HD streaming file, you will need to format your stream name slightly different: “mp4:NAME_OF_STREAM.mp4″
- Please note that you can not setup your NetStream until after the NetConnection has successfully connected. You will know this from the NetStatus event: NetConnection.Connect.Success that is dispatched.
var ns:NetStream = new NetStream(nc); ns.play("NAME_OF_STREAM"); // ns.play("mp4:NAME_OF_STREAM.mp4"); // this will stream an HD movie instead.
4.) That’s it! I hope this article has helped. Please comment below with any questions and I would be glad to help answer them.