Chaque étiquette flv a un horodatage et un décalage. Vous pouvez trouver la spécification FLV ici: http://download.macromedia.com/f4v/video_file_format_spec_v10_1.pdf
Vous ne pouvez lire la vidéo à aucune position. Vous devez commencer au début d'une balise, vous devrez donc trouver l'étiquette avec l'heure la plus proche de l'heure à laquelle vous voulez chercher.
Votre va vouloir faire quelque chose comme ceci:
private var tags:Array = [];
private var fileStream:FileStream;
private var netStream:NetStream;
private var seekTime:Number;
public function function readTags(path:String):void
{
//open the fileStream for reading
while(fileStream.bytesAvailable > 0)
{
//sudo code for reading the tags of an FLV
var tagPosition:int = fileStream.position;
var tagSize:int = //Read the tag size;
var timestamp:int = //read the timestamp;
tags.push({timestamp:timestamp, position:tagPosition}];
fileStream.position += tagSize; //goto the next tag
}
}
private function findTagPosition(timeInMilliseconds:int):int
{
//Search the tags array for the tags[a].timestamp that is nearest to timeInMilliseconds
return tags[indexOfTagNearstToTimeInMilliseconds].position;
}
public function seek(time:Number):void
{
seektime = time;
netStream.seak(time);
}
private function onNetStatusEvent(event:NetStatusEvent):void
{
if(event.info.code == NetStreamCodes.NETSTREAM_SEEK_NOTIFY)
{
fileStream.position = findTagPosition(seekTime * 1000);
netStream.appendBytesAction(NetStreamAppendBytesAction.RESET_SEEK);
var bytes:ByteArray = new ByteArray();
fileStream.readBytes(bytes);
netStream.appendBytes(bytes);
}
}