使用 Adob​​e AIR 从本地文件播放视频 [英] Play video from local file using Adobe AIR

查看:37
本文介绍了使用 Adob​​e AIR 从本地文件播放视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 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.Fileflash.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- 似乎接受一个 file://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

有人可以帮我吗?我特别想直接从本地磁盘加载和播放视频,而不是从网络服务器或流文件服务器...假设没有网络连接.

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);
}

这篇关于使用 Adob​​e AIR 从本地文件播放视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆