如何获取视频的字节数组?
How to get ByteArray of a Video?
我正在使用 this example 将 FLV 文件加载到我的项目中,这非常简单。它有效,但我想在加载视频后获取字节(如 ByteArray)。有什么方法可以执行此程序吗?
为方便起见,我使用 File
对象 (Adobe AIR) 加载文件,但没有找到将字节转换为 Video
对象的方法。
有谁知道如何加载视频文件并在加载后获取该对象的 ByteArray?
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);
我正在使用 this example 将 FLV 文件加载到我的项目中,这非常简单。它有效,但我想在加载视频后获取字节(如 ByteArray)。有什么方法可以执行此程序吗?
为方便起见,我使用 File
对象 (Adobe AIR) 加载文件,但没有找到将字节转换为 Video
对象的方法。
有谁知道如何加载视频文件并在加载后获取该对象的 ByteArray?
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);