Need a video player code in Actionscript 3. It is possible to play mp4 format video from any folder in my phone storage location ?
在Actionscript 3中需要视频播放器代码。可以从手机存储位置的任何文件夹播放mp4格式的视频吗?
1 个解决方案
#1
0
Since it's for mobile (using AIR), try using the File
class. It allows you to browse for files.
You can lock the file browsing to list only specific format(s) by using FileFilter
.
由于它适用于移动设备(使用AIR),请尝试使用File类。它允许您浏览文件。您可以使用FileFilter锁定文件浏览以仅列出特定格式。
Read the Adobe guide here : Working with File objects in AIR
.
在此处阅读Adobe指南:在AIR中使用File对象。
Below is an example code you can try. Untested at moment (but modified from this other Answer).
以下是您可以尝试的示例代码。暂时未经测试(但从其他答案修改)。
//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
}
#1
0
Since it's for mobile (using AIR), try using the File
class. It allows you to browse for files.
You can lock the file browsing to list only specific format(s) by using FileFilter
.
由于它适用于移动设备(使用AIR),请尝试使用File类。它允许您浏览文件。您可以使用FileFilter锁定文件浏览以仅列出特定格式。
Read the Adobe guide here : Working with File objects in AIR
.
在此处阅读Adobe指南:在AIR中使用File对象。
Below is an example code you can try. Untested at moment (but modified from this other Answer).
以下是您可以尝试的示例代码。暂时未经测试(但从其他答案修改)。
//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
}