需要 Actionscript 3 中的视频播放器代码。可以从我手机存储位置的任何文件夹中播放 mp4 格式的视频吗?
1 回答
0
由于它适用于移动设备(使用 AIR),请尝试使用File
该类。它允许您浏览文件。您可以使用
锁定文件浏览以仅列出特定格式FileFilter
。
在此处阅读 Adobe 指南:Working with File objects in AIR
.
以下是您可以尝试的示例代码。目前未经测试(但从另一个答案修改)。
//someGraphic is your own UI element (clicked/tapped) for user to begin file browse
someGraphic.addEventListener(MouseEvent.CLICK, browseVideo);
function browseVideo(evt:MouseEvent = null):void
{
var vidFiles : FileFilter = new FileFilter("Choose Video", " *.mp4 ; *.flv");
var file:File = new File();
file.addEventListener(Event.SELECT, onFileSelected);
file.browse([vidFiles]);
}
function onFileSelected(evt:Event):void
{
//auto-extract path to give to NS video player
playVideo(evt.currentTarget.nativePath);
}
function playVideo(video_path:String):void
{
// using a Video + NetStream object
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
ns.client = this;
var video:Video = new Video();
video.attachNetStream(ns);
addChild(video);
ns.play(video_path); //is using auto-extracted path
}
于 2016-11-24T03:14:52.653 回答