0
votes

I have loaded a flv video dynamically from as3 library. Now I want to rewind it, but code is not working. Showing:

Scene 1, Layer 'Layer 1', Frame 1, Line 64 1119: Access of possibly undefined property playheadTime through a reference with static type flash.media:Video..

Here is my code. I could not find the problem. Any help would be great.

stage.displayState = StageDisplayState.FULL_SCREEN; 
import flash.media.Video;
 import fl.video.FLVPlayback;
var connection:NetConnection = new NetConnection();
var stream:NetStream;
var Speed:Number;
var SeekPoint:Number;
var Rewind:Boolean ;
var  Forward:Boolean ;
var video:Video = new Video(1130,510);
var metaObj:Object = new Object();

function onMetaData(data:Object):void
{

}

connection.connect(null);
stream = new NetStream(connection);
stream.client = metaObj;
metaObj.onMetaData = onMetaData;
video.attachNetStream(stream);
addChild(video);
stream.play("Sequence 01_1.flv");
video.x = 0;
video.y = 0;
rw.addEventListener(MouseEvent.MOUSE_DOWN,  rw_CLICK);
function rw_CLICK(event:MouseEvent):void 
{

        trace("StartForward Called");
        Speed = Speed +10;
        trace("SeekSpeed: " + Speed);
        SeekPoint = video.playheadTime;
        trace("Initial PlayHead Time: " + SeekPoint);
        video.stop();
        Rewind = false
        Forward= true;
        //video.addEventListener(Event.FRAME_CONSTRUCTED,OnConstructFrame);

    }


function OnConstructFrame(event:Event):void
    {

        if(Forward)
        {
            if(video.playheadTime >= SeekPoint)
            {
                trace("Before Seek Cal.: " + SeekPoint);
                SeekPoint = SeekPoint + Speed;
                trace("After Seek Cal.: " + SeekPoint);
                video.seek(SeekPoint);
               /* if(SeekPoint > ftime)
                {
                    Forward=false;
                  //  video.removeEventListener(Event.FRAME_CONSTRUCTED,OnExitFrame);
                }*/
            }

        }
    }
1

1 Answers

0
votes

The VideoClass don't have a property playheadTime. You have to get the time-property of the NetStream-Object. Further there is no seek-method. Both are only available in the FLVPlayback-Component. You should use play(name, time)

If you are working with Netstreamand `Video' you can use this:

...
if(stream.time >= SeekPoint) //in seconds
{
     trace("Before Seek Cal.: " + SeekPoint);
     SeekPoint = SeekPoint + Speed;
     trace("After Seek Cal.: " + SeekPoint);
     stream.play("Sequence 01_1.flv", SeekPoint);
     /* if(SeekPoint > ftime)
     {
          Forward=false;
          //  video.removeEventListener(Event.FRAME_CONSTRUCTED,OnExitFrame);
     }*/
}
...

Greetings André