Flash Lite 2.x and 3.0 ActionScript Language Reference

seek (NetStream.seek method)

public seek(offset:Number) : Void

Seeks the keyframe closest to the specified number of seconds from the beginning of the stream. Playback resumes when this location is reached.

Availability

ActionScript 1.0; Flash Player 7

NOTE: This method is also supported in Flash Player 6 when used with Flash Media Server. For more information, see the Flash Media Server documentation.

Parameters

offset:Number - The approximate time value, in seconds, by which to move the playhead in an FLV file. The playhead moves to the keyframe of the video that's closest to the value specified by offset.

  • To return to the beginning of the stream, pass 0 to offset.
  • To seek forward from the beginning of the stream, pass the number of seconds you want to advance. For example, to position the playhead 15 seconds from the beginning, use my_ns.seek(15).
  • To seek relative to the current position, pass my_ns.time + n or my_ns.time - n to seek n seconds forward or backward, respectively, from the current position. For example, to rewind 20 seconds from the current position, use my_ns.seek(my_ns.time - 20).

The precise location to which the playhead moves differs according to the frames-per-second (fps) setting at which the video was exported. For example, suppose you have two video objects that represent the same video, one exported at 6 fps and the other at 30 fps. If you then use my_ns.seek(15) for both objects, the playhead moves to two different locations.

Example

The following example illustrates some ways to use the NetStream.seek() command. You can return to the beginning of the stream, move to a location 30 seconds from the beginning of the stream, and move backward three minutes from the current location:

// Return to the beginning of the stream
my_ns.seek(0);

// Move to a location 30 seconds from the beginning of the stream
my_ns.seek(30);

// Move backwards three minutes from current location
my_ns.seek(my_ns.time - 180);