I'm trying to layout some text fields from within a dynamic Strobe plugin. What's the basic workflow for getting the dimensions of the player? I assume it has something to do with LayoutMetadata? How would I get the players LayoutMetadata from within a loaded SWF?
I found the solution.
currentElement is a reference to the proxiedElement in my proxy plugin.
var dispTrait:DisplayObjectTrait = DisplayObjectTrait(currentElement.getTrait(MediaTraitType.DISPLAY_OBJ ECT));
var w = dispTrait.displayObject.width;
i tried using mediaWidth and layoutMetadata, which according to the docs should both have been available, but they consistenly returned "NaN".
This is extremely inconsistent, unreliable, and confusing.
Sometimes I get the actual width, other times I get 0 or NaN. It seems to change based on how many times I reload the page.
The documentation is zero help.
There's no out-of-the-box way for a dynamic plugin to get the dimensions of the loading player. The loading player would need to make this information available to the plugin. The solution that some other plugin developers have used is to have the player pass the Stage in as metadata on the resource that is used to load the plugin, e.g.:
var resource:URLResource = new URLResource("http://www.example.com/myplugin.swf");
The plugin would get the Stage in its overridden PluginInfo.initializePlugin method:
override public function initializePlugin(resource:MediaResourceBase):void
var stage:Stage = resource.getMetadataValue("http://www.example.com/mynamespace") as Stage;
In my opinion, passing the Stage as metadata would be a really nice OSMF (not SMP/FMP) improvement request.
We'd like to avoid having special metadata set on the SMP/FMP side since this might encourage developement of some SMP/FMP specific plugins, and we'd like to avoid this kind of fragmentation as much as possible. That's why we don't set any special metadata on the SMP/FMP side.
For your use case, I think you should try to get the DisplayObject using the snippet you outlined above; register resize events handlers on the displayObject.stage and use the values that are > 0. Note that SMP will remove/add the video from the stage in various situations for performance optimization reasons (for ex. before going into fullscreen).
Let us know how it goes,
I have been trying for hours to crack this nut. I want to listen to the size change events that (I assume) would be dispatched when calling MediaPlayerSprite.width (height, etc.). I have a plugin that, among other things, use a class that extends LightweightVideoElement. Within this classam listening to events from the layoutMetadata from the MediaContainer.
(I create a reference to the container in a ContainerChangeEvent handler)
I have the following listeners created:
Neither of these methods ever gets called.
When I step through the debugger, I can see the values change in the _container.layoutRenderer.layoutMetadata instance.
I reviewed the source code for LayoutMetadata (OSMF 1.5) and I can't see any mechanism for dispatching these events. I see several other metadata extension instances composed within this class (for example, LayoutAttributesMetadata), but none of their events are cloned and redispatched by LayoutMetadata.
Am I missing something here?
Europe, Middle East and Africa