3 Replies Latest reply on Jun 16, 2011 9:40 AM by ssebuser

    netStream client handler

    ssebuser

      Hi,

      I want to add an handler for onMetaData on my netStream Client.

      The onMetaData function is never called, but I know that the .flv file I'm playing contains metadata...

       

      public class CustomNetStream extends NetStream
      {

           public function CustomNetStream(connection:NetConnection)
           {

              super(connection);

       

              client = new NetClient();

              NetClient(client).addHandler(NetStreamCodes.ON_META_DATA, onMetaData);

       

              addEventListener(NetStatusEvent.NET_STATUS, onNetStreamStatus);

           }

       

           public function onMetaData(value:Object):void
           {
                 NetClient(client).removeHandler(NetStreamCodes.ON_META_DATA, onMetaData);
                
                 trace("Got metadata.");
            }

       

          private function onNetStreamStatus(event:NetStatusEvent):void
           {

             trace("onNetStreamStatus() - event.info.code=" + event.info.code);

           }

      }

        • 1. Re: netStream client handler
          Mykola3296

          Hello!

           

          Do you need to handle metadata in NetStream descendant?

           

          If not I would have used a different approach.

          LightWeightedVideoElement has a property "client" that is being set to NetClient upon element load.

           

          So you may want to load an element and use that property instead of subclassing netstream.

           

          Regards!

          • 2. Re: netStream client handler
            ssebuser Level 1

            I'm creating a dynamic OSMF plugin and I need to create a custom NetStream class.

            • 3. Re: netStream client handler
              ssebuser Level 1

              I found a way, when I receive NetStream.Play.Start I add the handler and then it works perfectly...

               

              private function onNetStreamStatus(event:NetStatusEvent):void
              {
                 trace("onNetStreamStatus() - event.info.code=" + event.info.code);     
                 if ( event.info.code == NetStreamEvent.PLAY_START )
                 {

                      var netStreamLoadTrait:NetStreamLoadTrait = loadTrait as NetStreamLoadTrait;
                      (netStreamLoadTrait.netStream.client as NetClient).addHandler(NetStreamCodes.ON_META_DATA, onMetaData);

                 }

              }