5 Replies Latest reply on May 5, 2010 8:28 AM by bringrags

    How to read MetaData

    bugreport22

      Hello,

       

      im trying to read some metadata which I add to the Media Element

       

      e.g.

       

      mediaElement.metadata.addValue("mediatitel", mediaList.media[i].mediatitel);

       

      how can I read this Metadata when the media element is on the stage

        • 1. Re: How to read MetaData
          bringrags Level 4

          The relevant APIs are MediaElement.addMetadata and MediaElement.getMetadata.  MediaElement also has events (metadataAdd and metadataRemove) for detecting changes dynamically.

          • 2. Re: How to read MetaData
            bugreport22 Level 1

            Brian, Im doing following:

             

                                var imageResource:URLResource = new URLResource(mediaList.media[i].@url);
                                var mediaElement:MediaElement = factory.createMediaElement(imageResource);
                                var metaData:Metadata = new Metadata();
                                metaData.addValue("mediatitel", mediaList.media[i].@mediatitel);
                                mediaElement.addMetadata("mediaInfos",metaData);

             

            then I add the Image Element to a serial Element

             

            then

             

                        mediaElement.addEventListener(MediaElementEvent.METADATA_ADD,onMetadataAdd);

             

            this event is never fired.

             

            when I want to read the metadata on the displayobjectchange event

             

            var metadata:Metadata = mediaElement.getMetadata("MediaInfos");

            trace(metadata.getValue("mediatitel");

             

            I got the metadata but not the one for the right element.

            • 3. Re: How to read MetaData
              bringrags Level 4

              I believe you're running into bug FM-811.  I have a local fix which will probably go into trunk today or tomorrow (as soon as the fix is approved).

              • 4. Re: How to read MetaData
                bugreport22 Level 1

                I used the latest revision and the mediaElement.addEventListener(MediaElementEvent.METADATA_ADD,onMetaData);

                 

                fires now but when the first element is showed for the first time the listener dont fire, when loop is true then on the next time the listener fires on the first element. On the second element etc. it fires ok

                • 5. Re: How to read MetaData
                  bringrags Level 4

                  Note that the event is for metadata that is added dynamically, there may already be metadata present before you add the listener (which you can check by calling MediaElement.get metadataNamespaceURLs).