views:

1877

answers:

2

I have gotten a NetConnection and NetStream set up and the streaming mp3 is playing fine. The only problem is the metadata is not received even though NetStream's client has been set. Any idea what could have caused this?

Code snippet:


// set up NetConnection
...

private function netStatusHandler(e:NetStatusEvent):void 
{
  if (e.info.code == "NetConnection.Connect.Success")
  {
    // NetConnection's connection established successfully
    netStream = new NetStream(nc);
    netStream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
    netStream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
    netStream.client = new NetStreamClient();

    netStream.play("mp3:music/123456");
  }
}

class NetStreamClient
{   
  public function onMetaData(info:Object):void
  {
    trace("onMetaData");
  }

  public function onPlayStatus(info:Object):void
  {
    trace("onPlayStatus");
  }
}
A: 

before the netStream.play( ) call add this:

netStream.onMetaData = function(infoObject:Object) {
    trace('on metadata:');
    for (var propName:String in infoObject) {
    trace(propName + " = " + infoObject[propName]);
}

does that work?

Jake
This approach is ok for AS2, but you are not allowed to do this for AS3 unless the class is dynamic. That's why NetStream's client property is used instead.
Boon
A: 

var client:Object = new Object( ); client.onMetaData = function(metadata:Object):void { trace(metadata.duration); }; videoStream.client = client;

Amur