问题描述
我想打使用Adobe AIR的,并从本地文件系统中读取视频,以及显示图像和其他可能的Flash内容。我一直在寻找的API,我还没有能够连接点。
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.
我知道 flash.filesystem.File将和 flash.filesystem.FileStream 并曾试验加载和读取文件。我相信我可以加载图像这种方式,但还没有尝试过。
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.
至于视频:
mx.controls.VideoDisplay当 - 似乎已经接受了一个文件:// URI源,但我不能让它的工作。
mx.controls.VideoDisplay- seems to accept a file:// URI for source, but I can't get it to work.
flash.media.Video - 接受的NetStream或可以直接从视频输入加载视频,似乎无法找到一个方法来引用本地文件
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
谁能帮助我在这里?我特别要加载,并直接播放视频关闭本地磁盘,而不是从Web服务器或流媒体文件服务器......假设没有网络连接。
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)
推荐答案
在脑海中使用我的要求是计划中的使用。我一直在寻找一种方式来直接使用ActionScript做到这一点。
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.
我终于迷迷糊糊到我希望的......使用NetStream对象的解决方案,但(非直觉),你可以用它来访问本地文件,以及:
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);
}
这篇关于从使用Adobe AIR本地文件播放视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!