1 Reply Latest reply on Jan 21, 2010 12:09 PM by Edwin van Rijkom

    control via JavaScript


      How much of OSMF is accessible from JavaScript out of the box? Is there documentation or sample code showing this?


      (This question comes from a customer.  Reposting here for the OSMF team to respond and for the benefit of the whole group.)

      Sumner Paine
      osmf product manager

        • 1. Re: control via JavaScript
          Edwin van Rijkom Level 2

          Hi Sumner,


          The framework has an HTMLElement class, which is the representation of a piece of media that is implemented in JavaScript. Then there is the HTMLMediaContainer class, that an HTMLElement can be assigned to. It sets up a connection with JavaScript using Flash's ExternalInterface feature.


          What happens next, is that inside JavaScript a callback method will triggered informing JavaScript that an HTMLElement got added from the SWF. At this point, it is up to the JavaScript in the hosting HTML document to tell the OSMF based application what the implementation of the media element is. We expose a small JavaScript API for this, that maps to 4 of our media element traits, namely the load trait, time trait, play trait and audio trait.


          If the aforementioned HTMLElement is part of a parallel composition, then it can excercise some control over its peers. The element triggering "pause" on its play trait (all from JavaScript), would result in all its peers being paused too. This way, one can create a banner, for example, that when clicked, pauses the content that is playing in the SWF. We have a sample that does this, at:


          http://opensource.adobe.com/svn/opensource/osmf/trunk/apps/samples/framework/HTMLMediaCont ainerSample/


          Hope it's helpful!