Wowza Community

simple actionscript 3 example

I recently started using Wowza with a view to setting up an elearning system with streaming video. However I am using actionscript 3 and I am having problems in getting any video to play at all.

Here is my code - just a simple example to do a proof of concept job…

var customClient:Object = new Object();
customClient.onCuePoint = cuePointHandler;
customClient.onMetaData = metaDataHandler;
var nc:NetConnection = new NetConnection();
nc.objectEncoding = ObjectEncoding.AMF0; 
nc.connect("rtmp://localhost:1935/simplevideostreaming");
nc.addEventListener(NetStatusEvent.NET_STATUS, statushandler);
var ns:NetStream;
var video:Video = new Video();
video.attachNetStream(ns);
function statushandler(e:NetStatusEvent):void
{
	//trace(e);
	if (e.info.code == "NetConnection.Connect.Success")
	{
		trace(e.info.code);
		
		ns = new NetStream(nc);
		ns.client = customClient;
		addChild(video);
 		ns.play("Extremists");
		
	}
}
function cuePointHandler(infoObject:Object):void 
{
    trace("cuePoint");
}
function metaDataHandler(infoObject:Object):void 
{
    trace("metaData");
}

I have looked through the forums and one of the issues was handling the metadata, and so i added the extra Object, but all that happens is my output tells me that i have successfully connected, but i see no video at all.

Does anyone have any ideas what i am doing wrong?

btw the server does work as i have used the supplied simple example (as2) and the video is served up.

Any help would be greatly appreciated.

I modified your code and it works for me:

var customClient:Object = new Object();
customClient.onCuePoint = cuePointHandler;
customClient.onMetaData = metaDataHandler;
var nc:NetConnection = new NetConnection();
nc.objectEncoding = ObjectEncoding.AMF0; 
nc.connect("rtmp://localhost:1935/simplevideostreaming");
nc.addEventListener(NetStatusEvent.NET_STATUS, statushandler);
var ns:NetStream;
var video:Video = new Video();
function statushandler(e:NetStatusEvent):void
{
	trace(e);
	if (e.info.code == "NetConnection.Connect.Success")
	{
		trace(e.info.code);
		
		ns = new NetStream(nc);
		ns.client = customClient;
		video.attachNetStream(ns); <-- move this to here
		addChild(video);
 		ns.play("Extremists");
		
	}
}
function cuePointHandler(infoObject:Object):void 
{
    trace("cuePoint");
}
function metaDataHandler(infoObject:Object):void 
{
    trace("metaData");
}

Charlie

much appreciated charlie - works perfectly - i did not realise that the attachNetStream was so picky in its placement :slight_smile: