4 Replies Latest reply on Dec 6, 2010 9:08 AM by bringrags

    Problem with seeking in serial element

    Amit Kumar Adobe Employee

      Hi,

       

      I have a osmf player where I am trying to play advertisement and then the main video so for this I am using serial element but the problem is with seeking in the main video which is played after advertisement. In the player side I am checking whether the seeking has been completed or not using :

       

      private

       

       

      function onSeekingChange(event:SeekEvent):void

      {

       

       

          if (event.seeking == false)

          {

               trace("Seeking is done!!");

          }

          else

               trace("Seeking is going on...");

      }

       

      And my player state continues to be in buffering and it never returns event.seeking as "false":

       

      private

       

       

      function _onMediaStateChange( play_event:PlayEvent ):

      void

      {

                _currentState = play_event.playState;

       

       

                trace("STATE: " + _currentState);

      }

       

      Is this a bug in player?

       

      Regards,

      Amit

        • 1. Re: Problem with seeking in serial element
          bringrags Level 4

          It's hard to say based on the limited code you've shared.  But in general, I'd recommend using the MediaPlayerStateChangeEvent to track state changes in the player, rather than the more granular SeekEvent, BufferEvent, etc.

          • 2. Re: Problem with seeking in serial element
            Amit Kumar Adobe Employee

            Hi Brian,

             

            After debugging too much into the framework I got to know the exact problem I will explain :

             

            In onSeek method I have following checks before we call seek method() :

             

            if

             

            ( _mediaPlayerCore.canSeek)

            {

             

               if( _mediaPlayerCore.canSeekTo( time ) )

               {

             

                    seekTrait.addEventListener(SeekEvent.SEEKING_CHANGE, onSeekingChange);

                    seekToTime = time;

                    seekTrait.seek(time);

                }

            }

             

            Case 1 : If we have only one media element then if we check for _mediaPlayerCore.canSeekTo( time ) before seeking then it goes to canseekTo() method of  NetStreamSeekTrait where it does following checking :

             

            override

             

            public function canSeekTo(time:Number):Boolean

            {

             

                      var result:Boolean = super.canSeekTo(time);

             

             

                      if ( result && !isNaN(loadTrait.bytesTotal) && loadTrait.bytesTotal > 0 )

                      {

             

                          // Check the progress of the download, as you can't seek past

             

             

                          // the last downloaded byte.

             

             

                          var maxSeekTime:Number = timeTrait.duration * Number(loadTrait.bytesLoaded / loadTrait.bytesTotal);

                          result = time <= maxSeekTime;

                      }

             

             

                      return result;

            }

             

            Based on the above checking it does not allow us to call seek method outside loaded bar and everything works fine.

             

            Case 2 : If we have two media elements one wrapped up in AdProxy and other normal mediaElement then we create serialElement and these two media elements in it and when first video is finished and we try to call seek outside the loaded bar or just at its boundary then it calls seek method and then it enters buffering state and it never comes out of it. Here it calls canSeekTo() method of CompositeSeekTrait where it again calls prepareSeekOperationInfo method of SerialSeekTrait where it sets "canseekTo" property of SerialSeekOperationInfo which is always set to true but I think it should again be checked like we did it in NetstreamSeekTrait:

             

            //CompositeSeekTrait.as

            override

             

            public function canSeekTo(time:Number):Boolean

            {

               

            return super.canSeekTo(time) && prepareSeekOperationInfo(time).canSeekTo;

            }

             

            if

             

            (curChildSeekOperation.relativeStart <= time && time <= curChildSeekOperation.relativeEnd)

            {

             

                  var timeTrait:TimeTrait = curChildSeekOperation.mediaElement.getTrait(MediaTraitType.TIME) as TimeTrait;

             

                  var loadTrait:LoadTrait = curChildSeekOperation.mediaElement.getTrait(MediaTraitType.LOAD) as LoadTrait;

             

                  seekToOp =

            new SerialSeekOperationInfo();

                  seekToOp.canSeekTo =

            true;

             

                  //Added by me to correct my problem

             

                  if ( !isNaN(loadTrait.bytesTotal) && loadTrait.bytesTotal > 0)

                  {

                       // Check the progress of the download, as you can't seek past

             

             

             

                       // the last downloaded byte.

             

                       var maxSeekTime:Number = timeTrait.duration * Number(loadTrait.bytesLoaded / loadTrait.bytesTotal);

             

                       if(time <= maxSeekTime)

                            seekToOp.canSeekTo =

            true;

             

                       else

                            seekToOp.canSeekTo =

            false;

                   }

             

                   seekToOp.fromChild = curChildSeekOperation.mediaElement;

                   seekToOp.toChild = curChildSeekOperation.mediaElement;

             

                   seekToOp.toChildTime = time - curChildSeekOperation.relativeStart;

            }

             

            So, Do you think it is an issue in the framework?  Let me know if I am correct.

             

            Regards,

            Amit

             

             

             

             

             

             

             

             

             

            • 3. Re: Problem with seeking in serial element
              bringrags Level 4

              My quick reaction is that your analysis and proposal make sense, though we'd probably need to look at this a bit closer to be sure.  Can you file a bug and include a small sample that reproduces the issue?  Thanks!