4 Replies Latest reply on Dec 19, 2010 12:08 AM by Jack Senechal

    Add Play, Seek and Time Traits to the SWFElement, StrobeMediaPlayback Conversion to Flex Component


      To whom can give me a hand with this, I am deeply grateful.  First I am attempting to convert StrobeMediaPlayback to a Flex Component in lieu of using the StrobeMediaPlayback.swf as it uses the stage to set the width and height and this will not work for what we are attempting to do. I have most of the conversion complete, however, I am stumped on adding traits to the SWFElement.  I would like to add Play, Seek and Time Traits to control a SWF using a SWFElement media element.  The issue I have is upon pressing the pause button the movieClip.stop() line is executed, however, the movieClip does not actually stop, it continues until it is complete.  My other issue is with the seek trait, the scrub bar will move to the appropriate time; however, nothing changes on the swf media despite the seekingChangeStart() code executing.


      I have left out most of the code for brevity but included the pieces I think would be the most important:


      I have added the traits to a SWFElement as shown below:


      public class SWFElement extends LoadableElementBase



      override protected function processReadyState():void


      var loaderLoadTrait:LoaderLoadTrait = getTrait(MediaTraitType.LOAD) as LoaderLoadTrait;

      movieClip = loaderLoadTrait.loader.content as MovieClip;


      addTrait(MediaTraitType.DISPLAY_OBJECT, LoaderUtils.createDisplayObjectTrait(loaderLoadTrait.loader, this));


      playTrait = new MovieClipPlayTrait(movieClip);

      addTrait(MediaTraitType.PLAY, playTrait);


      timeTrait = new MovieClipTimeTrait(movieClip);

      addTrait(MediaTraitType.TIME, timeTrait);


      seekTrait = new MovieClipSeekTrait(timeTrait, loaderLoadTrait, movieClip);

      addTrait(MediaTraitType.SEEK, seekTrait);


      audioTrait = new MovieClipAudioTrait(movieClip);

          addTrait(MediaTraitType.AUDIO, audioTrait);






      public class MovieClipPlayTrait extends PlayTrait



          override protected function playStateChangeStart(newPlayState:String):void


      if (newPlayState == PlayState.PLAYING)





      else // PAUSED || STOPPED












      public class MovieClipSeekTrait extends SeekTrait




      override protected function seekingChangeStart(newSeeking:Boolean, time:Number):void


      if (newSeeking)


      var frameRate:Number = 24;

      var frame:Number = Math.round(time * frameRate);











      Any help would be greatly appreciated.


      Thanks ahead of time!!!!

        • 1. Re: Add Play, Seek and Time Traits to the SWFElement, StrobeMediaPlayback Conversion to Flex Component
          Andrian Cucu Adobe Employee

          Hi Nathan,


          Can you provide some more details about your use case?


          Do you do the conversion of the StrobeMediaPlayback to a flex component because you need to control it's width and height?

          Do you need to need to control the StrobeMediaPlayback as an OSMF MediaElement by adding custom Traits on top of it?

          Do you need to control a specific SWF for which you create custom Traits and you play it using a flex component build on top of StrobeMediaPlayback?



          • 2. Re: Add Play, Seek and Time Traits to the SWFElement, StrobeMediaPlayback Conversion to Flex Component
            ncarnal@gmail.com Level 1

            Thanks Andrian for the quick response.


            1. Yes, I need to be able to control the width and height of the media.

            2. Additional traits (play, seek, time and audio) must be added to the SWFElement or a subclass.

            3. Yes, a flex component built on top of OSMF or StrobeMedia would be great, not sure I answered this question correctly.


            Ultimately, I need to be able to control .swfs just like video (play, seek, time, and audio) within a Flex application (Flex 3 at this time).  We currently have a player that does this albeit not the best looking thing and we wanted to begin using the OSMF as it provides more flexibility than our current player.  We have chosen StrobeMediaPlayback as we like the ControlBar and do not have the time to create the UI for a control bar


            To add the additional traits, I used the NetStreamTraitNameHere as examples to add the functionality to the SWFElement.  I was able to get the Audio piece working without issue as it does not affect the visual elements of the player; however my issues with the play, pause, resume and seek issues with scrub bar I am finding difficult to resolve.


            If you need my project to take a peek at the rest of the code, that can easily be arranged.


            I hope I have provided you with enough information to at least point me in the right direction.  I have looked through several pieces of documentation and different examples online and apparently I am overlooking something.  Knowing my luck it is something very small that I am just not seeing.


            Thanks again,



            • 4. Re: Add Play, Seek and Time Traits to the SWFElement, StrobeMediaPlayback Conversion to Flex Component
              Jack Senechal

              Hi Nathan,


              I'm finding myself in the same situation but not as far along. I need exactly the features you describe for a player I'm writing for online courseware, and I'm contemplating implementing play, seek, and time traits for SWFElement. Did you ever figure out the solution to your dilemma, and if so do you have any advice you might offer me in this undertaking?


              Many thanks!