Skip navigation
Currently Being Moderated

What's the best way to get the width of the player from within a dynamic plugin?

Sep 7, 2010 1:04 PM

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?

 

thanks

 
Replies
  • Currently Being Moderated
    Sep 8, 2010 10:01 AM   in reply to nerdabilly

    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");

    resource.addMetadataValue("http://www.example.com/mynamespace", stage);

    mediaFactory.loadPlugin(resource);

     

    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;

        ...

    }

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 8, 2010 12:31 PM   in reply to nerdabilly

    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,

    Andrian

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 13, 2010 9:43 PM   in reply to nerdabilly

    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:

    _container.layoutMetadata.addEventListener(MetadataEvent.VALUE_CHANGE, onLayoutChange);

    _container.layoutMetadata.addEventListener(MetadataEvent.VALUE_ADD,onL ayoutChange);

     

    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?

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points