2

I was looking for a way to go back and forth in my video using the seek function in AS3.

import flash.filesystem.File;
import flash.net.NetStream;

var nc:NetConnection = new NetConnection();
nc.connect(null);

var vid:Video = new Video(MovieClip(root).clip.width, MovieClip(root).clip.height)
MovieClip(root).clip.addChild(vid);
var ns:NetStream = new NetStream(nc);
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
vid.attachNetStream(ns);
function asyncErrorHandler(event:AsyncErrorEvent):void 
{}

var file: File = File.desktopDirectory;
var myFilter: FileFilter = new FileFilter("MP4;MOV", "*.mp4;*.mov");
file.addEventListener(Event.SELECT, loadImage);

function fn_open(e: MouseEvent): void {
file.browseForOpen("Open", [myFilter]);
}

function loadImage(e: Event): void {
ns.play(file.url);
ns.pause();
}  

var seek_value:int = 0
function fn_step(e: MouseEvent): void {
seek_value += 0.5
ns.seek(seek_value)
}

Unfortunately this works, but with seconds... is that possible to do so but with FPS or just a fraction of second? I've already tried entering decimal numbers inside the function, like net_stream.seek(0.5), but no results.

Any ideas?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62

0 Answers0