2 Replies Latest reply on Apr 26, 2010 9:02 AM by bringrags

    rewind when at swfelement in serialelement

    nyls

      I have a serialelement with as last element a swfelement. In the swfelement there is a 'play again' button.

       

      mediaplayer.stop() or   mediaplayer.seek(0) are not working because the swfelement doesn't support play, seek or stop through the mediaplayer.

       

      What would be the best approach to do a play again ?

       

      Thanks for any pointers,

       

      Niels

       

      [update]

       

      I started with subclassing swfelement to SeekableSwfElement to add a SeekTrait, now we canSeek but I can't figure out how to make a seek(0) work on the 'whole' mediaplayer 

       

      [/update]

        • 1. Re: rewind when at swfelement in serialelement
          nyls Level 1

          Ok, so found it ;-))

           

          By adding also a timeTrait we have canSeek and canSeekTo(0) to do a seek(0) and then a play !!!

           

           

          public class SeekableSwfElement extends SWFElement {
                  private var timeTrait : TimeTrait;

           

                  public function SeekableSwfElement(resource:URLResource=null, loader:ImageLoader=null)
                  {
                      super(resource);
                  }
                 
                  override protected function processReadyState():void
                  {
                      super.processReadyState();
                     
                      timeTrait = new TimeTrait();
                      addTrait(MediaTraitType.SEEK, new SeekTrait(timeTrait));
                      addTrait(MediaTraitType.TIME, timeTrait);
                     
                  }
                 
                  override protected function processUnloadingState():void
                  {
                      super.processUnloadingState();
                     
                      removeTrait(MediaTraitType.SEEK);
                      removeTrait(MediaTraitType.TIME);
                  }
              }
          }

          • 2. Re: rewind when at swfelement in serialelement
            bringrags Level 4

            An even simpler approach is to wrap the SWFElement in a DurationElement.  DurationElement provides the custom SeekTrait, TimeTrait, PlayTrait, etc. that you ended up implementing.  To see how this works, take a look at the "Timed Image" example in the ExamplePlayer sample:

             

            http://opensource.adobe.com/svn/opensource/osmf/trunk/apps/samples/framework/ExamplePlayer /org/osmf/examples/AllExamples.as