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?
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!
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.
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).
Neither of these are exactly what you're describing, but they should at least lead you a bit closer to your target.
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:
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();
// Construct a video element:
var video:MediaElement = osmf.factory.createMediaElement(new URLResource(VIDEO_URL));
// Add the metadata to the video's metadata:
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.
To access the metadata in the video file, you can use NetClient (which is exposed from VideoElement via the client property).
// Process metadata here.
Can I read the FLV metadata in the OSMF plugin itself?
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.
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);
var loadTrait:LoadTrait = mediaElement.getTrait(MediaTraitType.LOAD) as LoadTrait;
private function onLoadStateChange(event:LoadEvent):void
var videoElement:VideoElement = VideoElement(element);
Then I tried:
private function setupMediaFactory():void
factory = new DefaultMediaFactory();
private function onMediaElementCreation(e:MediaFactoryEvent):void
if (e.mediaElement is VideoElement)
var videoElement:VideoElement = e.mediaElement as VideoElement;
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 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?
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.
Thanks again. Just ignore the repost was not certain I had this in the right place.
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.
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.
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.