Reputation: 2325
I just wanted to make a simple Flash Player which can play rtmp streams using Flash ActionScript ...
Here is my code:
import flash.display.Sprite;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.media.Video;
import flash.events.*;
var nc : NetConnection;
var ns : NetStream;
var vid : Video;
var monitorBufferLengthEverySecond:uint;
var counter:uint;
vid=new Video();
vid.width=640;
vid.height=480;
trace("Create ... NetConnection");
nc = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatus);
nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, netSecurityError);
nc.connect("rtmp://x.x.x.x/live");
function netStatus(event:NetStatusEvent):void
{
trace("Net Satus: "+ event.info.code);
if(event.info.code == "NetConnection.Connect.Success")
{
trace("Net Satus is OK");
trace("Creating NetStream");
ns = new NetStream(nc);
var infoClient:Object = new Object();
infoClient.onMetaData = function oMD():void {};
infoClient.onCuePoint = function oCP():void {};
ns.client = infoClient;
ns.play("IPCamera.stream");
vid.attachNetStream(ns);
monitorBufferLengthEverySecond = setInterval(monPlayback, 1000);
}
}
function netSecurityError(event:SecurityErrorEvent):void
{
trace("Security error: " + event);
}
function monPlayback():void
{
// Print current buffer length
trace((++counter)+ " Buffer length: " + ns.bufferLength);
}
The connection is successful *but* when I try to check buffer I always get "0" length...And I can not able to see RTMP stream...
Why this happen? What I am do wrong? Any ideas?
Upvotes: 0
Views: 1527
Reputation: 349
ns.addEventListener(NetStatusEvent.NET_STATUS, netStatus);
you can add this listener to the NetConnection and to the NetStream object , with that you will see whats your stream status im guessing you are not accesing the name of the stream correctly but cant tell for sure.
Use this to check your stream is available : http://www.osmf.org/configurator/fmp/
Upvotes: 1