1 Reply Latest reply on Dec 7, 2009 9:09 AM by bringrags

    seek fail on play start.

    Zallesov Alexander

      Hello everybody.

      We are developing web television service. And we hope to use osmf framework in a new version. I've just played with sample (HelloWorld) apps and encountered several problems. First is about seek function.

      For example I want to seek to N position right after i start to play media (flv video). First i tried this.

       

      public function HelloWorld()

      {

           var sprite:MediaPlayerSprite = new MediaPlayerSprite();

          addChild(sprite);

          sprite.element = new VideoElement( new NetLoader, new URLResource(new URL(REMOTE_PROGRESSIVE))        );

          sprite.mediaPlayer.seek(10);

      }

       

       

      it did play the video but did not seek. Then i tried this (HelloWorld4)

       

      public function HelloWorld4()
      {
          element = new VideoElement
              ( new NetLoader
              , new URLResource(new URL(REMOTE_PROGRESSIVE))
              );
         
          var x:* = element.gateway;
          var loadable:ILoadable = element.getTrait(MediaTraitType.LOADABLE) as ILoadable;
          loadable.addEventListener(LoadableStateChangeEvent.LOADABLE_STATE_CHANGE, onLoaded);
          loadable.load();
         
          function onLoaded(event:LoadableStateChangeEvent):void
          {
              if (event.newState == LoadState.LOADED)
              {
                  loadable.removeEventListener(LoadableStateChangeEvent.LOADABLE_STATE_CHANGE, onLoaded);
                 
                  var viewable:IViewable = element.getTrait(MediaTraitType.VIEWABLE) as IViewable;
                  addChild(viewable.view);
                  var seekable:ISeekable = element.getTrait(MediaTraitType.SEEKABLE) as ISeekable;
                  seekable.seek(100);
                  var playable:IPlayable = element.getTrait(MediaTraitType.PLAYABLE) as IPlayable;
                  playable.play();

                 
              }
          }
      }

      It did not work. (i also moved seek and play between each other).

      I succeed with seeking by attaching it to mouse event. It seems to me that seek is only possible when seek position is already loaded. Is that true?


      Please tell me what i'm doing wrong? Is there any way to seek anywhere right after play starts. Or it could be possible only with osmf 0.8 when SubClips are done?

       

      (REMOTE_PROGRESSIVE - is the url to the flv file on server that support progressive download)

        • 1. Re: seek fail on play start.
          bringrags Level 4

          A couple of suggestions:

          1) Seek can be asynchronous, so you might need to wait until the seek completion event before calling play.  If you make this change and it still doesn't work, I recommend you file a bug.

          2) It sounds like what you're trying to do is play a subclip of the video, for which we will have framework-level support in our next drop (code is already checked into public trunk).  See the Subclip Spec for details.