3 Replies Latest reply on Feb 8, 2012 1:46 AM by (Tony)

    difficulty pulling the metadata off a video

    WebAppEngineer

      I’m having difficulty pulling the metadata off a video file.

       

      I have trying two different ways.

       

      First I tried:

       

      mediaElement = createMediaElement(url);

                

      if (mediaElement)

      {

        

          var loadTrait:LoadTrait = mediaElement.getTrait(MediaTraitType.LOAD) as LoadTrait;

          loadTrait.addEventListener(LoadEvent.LOAD_STATE_CHANGE, onLoadStateChange);

      }

       

      private function onLoadStateChange(event:LoadEvent):void

      {

          switch (event.loadState)

          {

              case LoadState.READY:

                  var videoElement:VideoElement = VideoElement(element);

                  videoElement.client.addHandler(NetStreamCodes.ON_META_DATA, onMetadata);

                  break;                  

          }

      }

       

       

      Then I tried:

       

      private function setupMediaFactory():void

      {

          factory = new DefaultMediaFactory();

          factory.addEventListener(MediaFactoryEvent.MEDIA_ELEMENT_CREATE,onMediaElementCreation);

      }

       

       

      private function onMediaElementCreation(e:MediaFactoryEvent):void

      {

          if (e.mediaElement is VideoElement)

          {

              var videoElement:VideoElement = e.mediaElement as VideoElement;

              videoElement.client.addHandler(NetStreamCodes.ON_META_DATA, onMetadata);

          }

      }

       

      Both ways I get the same error:

       

      TypeError: Error #1009: Cannot access a property or method of a null object reference.

          at org.osmf.elements::VideoElement/get client()[C:\Documents and Settings\User\My Documents\OSMFs10\OSMF\org\osmf\elements\VideoElement.as:151]

          at OSMFPlayer/onMediaElementCreation()[C:\Documents and Settings\User\My Documents\OSMFs10\OSMFPlayer\src\OSMFPlayer.as:221]

          at flash.events::EventDispatcher/dispatchEventFunction()

          at flash.events::EventDispatcher/dispatchEvent()

          at org.osmf.media::MediaFactory/createMediaElement()[C:\Documents and Settings\User\My Documents\OSMFs10\OSMF\org\osmf\media\MediaFactory.as:363]

          at OSMFPlayer/createMediaElement()[C:\Documents and Settings\User\My Documents\OSMFs10\OSMFPlayer\src\OSMFPlayer.as:376]

          at OSMFPlayer/loadURL()[C:\Documents and Settings\User\My Documents\OSMFs10\OSMFPlayer\src\OSMFPlayer.as:294]

          at OSMFPlayer()[C:\Documents and Settings\User\My Documents\OSMFs10\OSMFPlayer\src\OSMFPlayer.as:183]

          at Preloader/onLoaderComplete()[C:\Documents and Settings\User\My Documents\OSMFs10\OSMFPlayer\src\Preloader.as:94]

       

      What am I doing wrong here?