I have the following code inside Adobe Media Server's main.asc
(latest version, 5.0.10 I think):
application.onPublish = function (clientObj, streamObj) {
for (var i = 0; i < application.clients.length; i++){
application.clients[i].call("streamConnected");
}
}
And this code inside my ActionScript (3.0) file, connected to my flash file:
nc = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, onConnectionStatus);
nc.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
nc.client = { onBWDone: function():void{}, streamConnected: function():void{} };
nc.connect(videoURL);
...
public function streamConnected(...rest):void {
trace("Stream Connected");
}
I'm not too sure what my code means - most of it has been sourced from various sections of the Internet, so any help would be greatly appreciated.
Using your current code, the only function that will be executed is the empty one which is defined inside the
nc.client
object because thestreamConnected()
function is not attached to thenc.client
'sstreamConnected
property.So, to get the
"Stream Connected"
message, you can change that anonymous function like this for example :or simply you can use your existing
streamConnected()
function :Hope that can help.