3 Replies Latest reply on Aug 1, 2006 10:58 PM by Renaun_Erickson

    Setting playheadTime in VideoDisplay

    syoavc Level 1
      I encountered a weird behaviour of the playheadTime setter in the VideoDisplay component.
      It seems like I'm getting the right value from it, but when I'm trying to set it - the playhead jumps to an unexpected point in the video.
      In the code below I'm setting the playheadTime to "1" when the "skip" button is pressed, but it is actually jumping to the 6.974s point in the video.
      Can you tell me what I'm doing wrong?

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
      <mx:Panel x="22" y="66" layout="absolute" width="572" height="474">
      <mx:VideoDisplay id="mainVid" y="10" maintainAspectRatio="true" source=" http://youtube-221.vo.llnwd.net/d1/03/1A/4YrMAI1vhnM.flv" autoPlay="false" horizontalCenter="0"/>
      <mx:HBox x="186" y="262">
      <mx:Button label="Play" click="mainVid.play();"/>
      <mx:Button label="Pause" click="mainVid.pause();"/>
      <mx:Button label="Stop" click="mainVid.stop();"/>
      </mx:HBox>
      <mx:Button label="Skip" click="mainVid.playheadTime=1" x="271" y="304"/>
      <mx:TextInput x="360" y="292" width="51" height="24" text="{mainVid.playheadTime}" />
      </mx:Panel>
      </mx:Application>
        • 1. Re: Setting playheadTime in VideoDisplay
          Renaun_Erickson Level 1
          This has to do with the FLV format and not the VideoDisplay control. The NetStream.seek() function which VideoDisplay encapsulates can only seek to key frames.

          A Key Frame in a video is a frame that is redrawn completely. When you are compressing your FLV's you have many options to set for Key Frames. The more Key Frames you have the bigger the file size, most FLV's are probably compressed at 15-30 fps and will have their Key Frame rate set to every 50-100. At 30 fps and every 100 frames make a key frame you are actually only getting new key frame every ~3 seconds.

          No when the NetStream.seek() function is called it finds the closest Key Frame after the time value you give it. So basically the video you are watching has a Key Frame at 0 seconds and 6.974s.
          • 2. Re: Setting playheadTime in VideoDisplay
            syoavc Level 1
            So the behaviour I encountered is not so weird after all... :)

            Thanks for your reply, Renaun.
            It was really helpful.
            • 3. Re: Setting playheadTime in VideoDisplay
              Renaun_Erickson Level 1
              Glad it helped, sorry there wasn't a better solution, but it is what it is. Compressing video for the web opens a can of worms, but its so much fun.