I'd like to play videos, as well as display images and possibly other flash content using adobe air, and reading from the local file system. I've been searching APIs and I have not yet been able to connect the dots.
I know of flash.filesystem.File and flash.filesystem.FileStream and have experimented with loading and reading files. I believe I can load images this way but haven't tried.
As for video:
mx.controls.VideoDisplay - seems to accept a file:// URI for source, but I can't get it to work.
flash.media.Video - accepts a NetStream or can load video directly from a video input, can't seem to find a way to reference a local file
Can anyone help me out here? I specifically want to load and play video directly off the local disk, not from a web server or a streaming file server... assume no network connectivity.
Slightly related question: Loading a video from the local file system… (but my question does not involve a web browser)
The use I have in mind is required to be programmatic in usage. I was looking for a way to do this directly with ActionScript.
I finally stumbled onto the solution I was hoping for... using a NetStream object, but (non-intuitively) you can use this to access local files as well:
private function playVideo():void {
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
# onMetaData listener is required otherwise you get a ReferenceError
var client:Object = new Object();
client.onMetaData = function(metadata:Object):void {
trace(metadata.duration);
}
ns.client = client;
var v:Video = new Video();
v.attachNetStream(ns);
stage.addChild(v);
var f:File = new File("/tmp/test.flv");
ns.play(f.url);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With