Playing RTMP streams needs to be done differently that progressive ones.
First you need to connect to the application, usually this is the base path but can sometimes be some folder up in case the RTMP server proposes different services.
You then need to listen to the NetConnection.Connect.Success
event dispatched by the NetConnection
event.
Once the NetConnection is connected you can create a NetStream
upon it and thereafter play the stream.
Note that the argument passed to the play command should only be the name of the stream and not the full path. Normally you also need to remove the extension (depends on server and service). For H264 streams you may also need to prefix the stream id with "mp4:".
Example :
// rtmp://myserver.com/service/myVideo.flv
var service:String = "rtmp://myserver.com/service/";
var streamID:String = "myVideo"; // or mp4:myVideo for H264
var netConnection:NetConnection;
var netStream:NetStream;
netConnection = new NetConnection();
netConnection.client = {onBWDone:onNetConnectionBWDone};
netConnection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
netConnection.connect(service);
// NetConnection status handlers
function netStatusHandler( event:NetStatusEvent ):void
{
if(event.info.code == NetConnection.Connect.Success)
{
netStream = new NetStream(netConnection);
netStream.client = {onMetaData:onMetaData, onPlayStatus :onPlayStatus};
netStream.play(streamID);
}
}
function onNetConnectionBWDone():void{}
// NetStream Status handlers
function onMetaData(o:Object):void{}
function onPlayStatus(o:Object):void{}