Developing applications using Flex and the Wowza Pro server

To develop client side applications that work with the Wowza Pro server you must set the objectEncoding parameter to ObjectEncoding.AMF0 on the NetConnection2 object before connecting to the Wowza Pro server.

The Flex client side code looks like this:

var wowzaURL:String = "rtmp://localhost/myapplication";
wowza_conn = new NetConnection2();
wowza_conn.objectEncoding = ObjectEncoding.AMF0; 
wowza_conn.connect(wowzaURL);

Charlie

the NetConnection2 class is that a class which extends NetConnection and has some added methods which Wowza requires?

We’re trying to migrate from FMS to Wowza, but I get an error when I try streaming audio saying:

AsyncErrorEvent type=“asyncError” bubbles=false cancelable=false eventPhase=2 text=“Error #2095: flash.net.NetStream was unable to invoke callback onMetaData.” error=ReferenceError: Error #1069: Property onMetaData not found on xxxx

Here’s a complete mxml file for a simple app. It will run against the VideoChat example included with the Wowza server, though it only uses the audio channels.

<?xml version="1.0" encoding="utf-8"?>

<mx:Application creationComplete=“initAudio()” backgroundGradientColors="[0xFFFFFF,0xFFFFFF]" xmlns:mx=“http://www.adobe.com/2006/mxml

horizontalAlign=“center” verticalGap=“5” horizontalGap=“5” width=“215” height=“140” layout=“vertical” verticalAlign=“top”>

mx:Script

</mx:Script>

<mx:Button enabled=“false” id=“pushToTalkButton” label=“Push to Talk” mouseOut=“stopTalk()” mouseUp=“stopTalk()” mouseDown=“startTalk()”/>

<mx:CheckBox enabled=“false” id=“muteCheckBox” label=“Mute” click=“onMuteChange()”/>

<mx:Label text=“Loading…” id=“statusLabel”/>

</mx:Application>

Hi Charlie, at the beginnign of this you had talked about NetConnection2 being used by Wowza and seemed to suggest that Flex clients use that. Can you please tell me what Wowza uses NetConnection2 for and is it better that I use that instead of NetConnection? Thanks

I don’t know Flex2 but from the error message it looks like you need to add the onMetaData handler to your NetStream object. In Flash you do something like…

var ns:NetStream = new NetStream(nc);
ns.onMetaData = function(infoObj)
{
     trace("onMetaData: "+infoObj);
};

I found this link:

http://osflash.org/pipermail/osflash_osflash.org/2006-June/009196.html

That says for Flex2 the syntax is something like:

// in your init method
ns.onMetaData = Delegate.create(this, onMetaDataHandler);
// then define the onMetaDataHandler
public function onMetaDataHandler(obj:Object):Void
{
}

Let me know if this helps.

Charlie

I do not know of any NetConnection2. I must have mis-typed.

Charlie

Try this

public function connect():void
{
nc = new NetConnection();
var client:Object = new Object();					
client.onMetaData = onMetaData;				
client.onBWDone = onBWDone;					
nc.client = client;
nc.objectEncoding = ObjectEncoding.AMF0;
nc.addEventListener( NetStatusEvent.NET_STATUS, netStatusHandler );
}
private function onMetaData():void
{
trace("onMetaData");
}
private function onBWDone():void
{
trace("onBWDone");
}

You might have to add the Module to the Modules list in your Application.xml

bwcheck

Bandwidth Checker

com.wowza.wms.plugin.bwcheck.ModuleBWCheck2

Put it last, below the other Modules.

Richard

btw, this line is obsolete. You do not need it, and should remove it:

nc.objectEncoding = ObjectEncoding.AMF0;

Richard

Try this version:

var bw:String = "";
public function onBWDone(... rest):void {
	if (rest.length > 0) 
	{
	bw = rest[0];
	trace(rest[0]);
	}
};

Richard

Try this

public function connect():void
{
nc = new NetConnection();
var client:Object = new Object();					
client.onMetaData = onMetaData;				
client.onBWDone = onBWDone;					
nc.client = client;
nc.objectEncoding = ObjectEncoding.AMF0;
nc.addEventListener( NetStatusEvent.NET_STATUS, netStatusHandler );
}
private function onMetaData():void
{
trace("onMetaData");
}
private function onBWDone():void
{
trace("onBWDone");
}

Hi,

I’m trying your code. But the onBWDone method is never triggered.

What may be the cause?

The netStatusEvent returns: NetConnection.Connection.Success.

I’m using Flex3 and Wowza Pro10

Thanks

Ok!

I’m getting into the onBWDone method. But how do I get the detected bandwith and/or other parameters?

function onBWDone(obj:Object) -> gives error: expected parameter 1, got 0

Thanks a lot already.

Greets

Hi,

I figured it out…

Thanks a lot!

Maarten

Hi. tell me, please, is there a way to force wowza use AMF3 in iclient.call() manually?