Reputation: 283
I am using this example to load a FLV file to my project, it's very simple. It works, but I would like to get the bytes (as ByteArray) after I load the video. Is there any way I can perform this procedure?
For convenience, I was using the File
object (Adobe AIR) to load the file, but have not found a way to convert the bytes to a Video
object.
Does anyone have any idea how I can load a video file and, after loading, get the ByteArray of this object?
Upvotes: 0
Views: 1270
Reputation: 1716
var connection:NetConnection = new NetConnection();
connection.connect(null);
var stream:NetStream = new NetStream(connection);
var client:Object = {};
client.onMetadata = function():void{};
stream.client = client;
var video:Video = new Video();
addChild(video);
video.attachNetStream(stream);
stream.play(null);
stream.appendBytesAction(NetStreamAppendBytesAction.RESET_BEGIN);
var file:File = new File("path/to/your/video.flv");
var fileStream:FileStream = new FileStream();
fileStream.open(file, FileMode.READ);
// this gives you access to the raw bytes of the file
var bytes:ByteArray = new ByteArray();
fileStream.readBytes(bytes);
// this adds the bytes to the NetStream and begins playback
stream.appendBytes(bytes);
Upvotes: 2