13 Replies Latest reply on Mar 30, 2010 9:50 AM by WebAppEngineer

    OSMF Metadata: setting persistent KeyValueFacets?

    blueberrykefir

      I'm fairly new to the wonderful world of OSMF, but I've hit a slight snag and I hope that someone could help me with my questions.

       

      There is a MetadataSample example that can be used to set various OSMF metadata KeyValueFacet values.

      And there's a MetadataVideoSample example that sets a KeyValueFacet value inside the application itself.

       

      However, I'd need to know how one can, using OSMF, set metadata values in one OSMF/Flash application and read them in another OSMF/Flash application, if possible.

       

      Thanks in advance!

        • 1. Re: OSMF Metadata: setting persistent KeyValueFacets?
          bringrags Level 4

          Much has changed with how metadata is modeled in OSMF, so I'd highly recommend you upgrade to the Sprint 10 release.  (For one thing, the two samples you mention have been removed, and there are no longer any "facet" classes.)

           

          Also, can you describe in more detail what you're trying to do?  You mention passing metadata values from one app to another, but what is the metadata you'd like to pass, and how does the second app respond to it?

          • 2. Re: OSMF Metadata: setting persistent KeyValueFacets?
            blueberrykefir Level 1

            Thanks for the help! (Yes, I've changed my forum name.)

             

            This is what I want to do:

             

            When I play an flv file, a plugin is loaded that looks for specific metadata tags.

             

            If found, the plugin will then send the metadata and the current time position for the flv file being played to another Flash application or, failing that, in another part of the application.

             

            You wouldn't know which example I should look at?

             

            Thanks in advance!

            • 3. Re: OSMF Metadata: setting persistent KeyValueFacets?
              bringrags Level 4

              The CaptioningSample demonstrates how the CaptioningPlugin looks for some metadata on the passed-in resource (in this case, the URL to the captioning document), and uses it to retrieve the captioning document, parse it, and generate the runtime metadata for captions.

               

              http://opensource.adobe.com/svn/opensource/osmf/trunk/apps/samples/plugins/CaptioningSampl e/

               

              On the other hand, if your goal is to have your plugin listen to the video as it's being played and capture information such as playback time, you might want to look at the ControlBarPluginSample.  In this case, the app loads the ControlBarPlugin, which is a visual plugin that listens to the media being played, and can control it (e.g. if the user clicks on the Play button in the control bar).

               

              http://opensource.adobe.com/svn/opensource/osmf/trunk/apps/samples/plugins/ControlBarPlugi nSample/

               

              Neither of these are exactly what you're describing, but they should at least lead you a bit closer to your target.

              • 4. Re: OSMF Metadata: setting persistent KeyValueFacets?
                blueberrykefir Level 1

                I've looked at http://opensource.adobe.com/svn/opensource/osmf/trunk/apps/samples/plugins/Contr olBarPluginSample/

                 

                The problem with this example is, as far as I can tell, that it doesn't really use the metadata in the flv file.

                What it does is that it appends temporary metadata information to the existing metadata values while the application is running:

                 

                In ControlBarPluginSample.as:

                 

                private function constructVideoElement():MediaElement

                {

                // Construct a metadata object that we can append to the video's collection

                // of metadata. The control bar plug-in will use the metadata to identify

                // the video element as its target:

                 

                var controlBarTarget:Metadata = new Metadata();


                controlBarTarget.addValue(ID, "mainContent");

                 

                 

                // Construct a video element:

                 

                var video:MediaElement = osmf.factory.createMediaElement(new URLResource(VIDEO_URL));

                 


                // Add the metadata to the video's metadata:

                 

                video.addMetadata(ControlBarPlugin.NS_CONTROL_BAR_TARGET, controlBarTarget);

                return video;

                }

                So it's not actually using the metadata that's already in the file.

                What I want to do is to use the already existing metadata in the file and not appended, temporary metadata.

                 

                Unless I've misunderstood something horribly, of course.

                • 5. Re: OSMF Metadata: setting persistent KeyValueFacets?
                  bringrags Level 4

                  To access the metadata in the video file, you can use NetClient (which is exposed from VideoElement via the client property).

                   

                  videoElement.client.addHandler("onMetaData", onMetadata);


                  function onMetadata(info:Object):void

                  {

                     // Process metadata here.

                  }

                  • 6. Re: OSMF Metadata: setting persistent KeyValueFacets?
                    blueberrykefir Level 1

                    Can I read the FLV metadata in the OSMF plugin itself?

                    • 7. Re: OSMF Metadata: setting persistent KeyValueFacets?
                      bringrags Level 4

                      Yes, provided that you have access to the VideoElement.  If your plugin creates the VideoElement, then that's no problem.  If not, then you would need to gain access to it.  The simplest way is to have your plugin provide a mediaElementCreationNotificationFunction (on PluginInfo).  This method will be invoked for every MediaElement created by the player's MediaFactory.

                      • 8. Re: OSMF Metadata: setting persistent KeyValueFacets?
                        WebAppEngineer

                        I am having a similar issue.

                        The only difference for me is that I’m not trying to access the metadata form inside the plugin.

                        I think I understand the solution but I’m having trouble implementing it.
                        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 way 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?

                        • 9. Re: OSMF Metadata: setting persistent KeyValueFacets?
                          bringrags Level 4

                          What you're doing looks correct.  I believe you're running into a bug that we fixed in public trunk after the Sprint 10 release.  Checking SVN, looks like the fix went in on 3/10.

                          • 10. Re: OSMF Metadata: setting persistent KeyValueFacets?
                            WebAppEngineer Level 1

                            Thanks again. Just ignore the repost was not certain I had this in the right place.

                            • 11. Re: OSMF Metadata: setting persistent KeyValueFacets?
                              WebAppEngineer Level 1

                              Okay I have the latest from trunk and I'm no longer getting the errorr message which is good so something was fixed. However regardless of which of the two ways I attempt, the event never fires so I think there may still be an issue here. Any ideas on if it is my side or osmf?

                               

                              Thanks again for all the help.

                              • 12. Re: OSMF Metadata: setting persistent KeyValueFacets?
                                bringrags Level 4

                                Do you have autoPlay set to true?  If so, try setting it to false.  It's possible that the onMetaData call is getting triggered before you add your handler.

                                • 13. Re: OSMF Metadata: setting persistent KeyValueFacets?
                                  WebAppEngineer Level 1

                                   

                                  Sorry for the late reply I was out of town for a few days.

                                  I’m using osmfplayer which by default is autoplay true and for some reason setting it to autoplay false is not working. And regardless of this I will need it to be autoplay true at times, which means I need the metadata regardless of the autoplay setting.

                                   

                                  I'm just going to start a new dicussion to prevent confussion.