Extracting metadata object from MediaElement (AS3)
I am attempting to retrieve metadata from a URLResource. The URLResource is not controlled by me, but passed into a function that I am using.
The URLResource is created like this:
var resource:URLResource = new URLResource("http://mediapm.edgesuite.net/osmf/content/test/logo_animated.flv");
// Add Metadata for the URLResource
var VideoParams:Object = {
Name:"Logo Video",
Owner:"Self",
Duration:"1:25:20",
category:"education"
}
resource.addMetadataValue("VideoParams", VideoParams);
var media:MediaElement = factory.createMediaElement(resource);
Now the URLResource contains the metadata. I will recieve a MediaElement resource. How do I extract the metadata back?
Here's what the debugger shows (media is a MediaElement object containing the URLResource w/ metadata) :
fdb>print media.resource.
$1 = [Object 246396705, class='org.osmf.media::URLResource']
_mediaType = null
_metadata = [Object 416970209, class='flash.utils::Dictionary']
_mimeType = null
url = "http://mediapm.edgesuite.net/osmf/content/test/logo_animated.flv"
fdb>print media.resource._metadata.
$2 = metadata = [Object 416970209, class='flash.utils::Dictionary']
VideoParams = [Object 416970305, class='Object']
(fdb)print media.resource._metadata.VideoParams.
$3 = VideoParams = [Object 416970305, class='Object']
category = "education"
Duration = "1:25:20"
Owner = "Self"
Name = "Logo Video"
I've attempted extracting the metadata object with:
media.resource.getMetadata("VideoParams");
开发者_开发知识库and a host of other attempts, but can't figure out how to get at that darned metadata.
Any thoughts greatly appreciated!
This actually turned out to be pretty easy...just needed to use the getMetadataValue function in the URLResource object like this:
var temp:Object = media.resource.getMetadataValue("VideoParams");
trace('Owner:', temp.Owner);
精彩评论