Skip navigation
Currently Being Moderated

MediaFactory and Plugins

Dec 13, 2011 10:58 AM

I have a working OSMF player that I'm trying to use plugins to expand the features and I need some clarification on how the factory works.

 

I have some code like this

 

_mediaElement = _mediaFactory.createMediaElement( _dynResource );

captionMetadata = new TimelineMetadata(_mediaElement);

_mediaElement.addMetadata(CaptioningPluginInfo.CAPTIONING_TEMPORAL_MET ADATA_NAMESPACE, captionMetadata);

captionMetadata.addEventListener(TimelineMetadataEvent.MARKER_TIME_REA CHED, captionHandler);

 

// _mediaElement.smoothing = true;

_mediaContainer.addMediaElement(_mediaElement);

_mediaPlayer.media = _mediaElement;

 

Before I used the factory to add the captioning data I was just creating a VideoElement allowing me to do the smoothing that is now commented out. I thought that the factory would create a MediaElement which i could then cast to a VideoElement to be able to turn on smoothing but instead the Factory is returning a org.osmf.captioning.media.CaptioningProxyElement which will not cast to a VideoElement. I plan on adding more plugins and it doesn't feel correct to have multiple levels of casting especially since the the experiments I've tried on that front seem to break the listeners on the captioning.

 
Replies
  • Currently Being Moderated
    Dec 14, 2011 6:09 AM   in reply to johnnicholas

    CaptioningProxyElement.proxiedElement should be your original media element (VideoElement in your case) i guess?

     

    I can't guarantee this would work, but maybe:

     

    if( _mediaElement is ProxyElement )

        (_mediaElement.proxiedElement as VideoElement).smoothing = true;

     

    Hope that helps,

    mark

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 27, 2012 2:02 AM   in reply to TheRossman

    Hi,

    It looks like you are adding the metadata directly to the MediaElement?

    I thought the thing to do was to add the metadata to the URLResource before using MediaFactory to generate the MediaElement? That way, the element is properly populated without the need for any intervention.

    G

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 27, 2012 2:06 AM   in reply to Gaius Coffey

    Oops... But I didn't answer the question!

     

    What I did (which is nasty, but it is effective) is to subclass the DefaultMediaFactory and modify the resolveItems function so that it will recurse down to video and set it there.

    EG: Something like:

    [code]

     

    protected function smoothElement(initElement:MediaElement):void {

    var element:MediaElement = recurseForProxies(initElement);

    if(!element) {

      trace("Oops! Nothing to smooth. "+initElement);

      return;

    }

    if( element is VideoElement )

    {

      VideoElement( element ).smoothing = smoothing;

      VideoElement( element ).deblocking = deblocking;

     

      trace("\t\t(Video smoothed.)");

    } else if( element is ImageElement) {

      ImageElement( element ).smoothing = smoothing;

    }

    }

    protected function recurseForProxies(element:MediaElement):MediaElement {

    if(element is ProxyElement) return recurseForProxies((element as ProxyElement).proxiedElement);

    if(element is SerialElement) return recurseForProxies((element as SerialElement).currentChild);

    return element;

    }

    [/code]

     
    |
    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