Need a video player code in Actionscript 3. It is possible to play mp4 format video from any folder in my phone storage location ?
Asked
Active
Viewed 577 times
-1
-
I think you got down-voted because of your **programming / technical** Question quality. Try to show code of what you've tried so we can help you fix it. Short sentences are for psychics and/or Google. Consider this : _"Need a..."_ = No freebie requests allowed, _"It is possible..?"_ = Check the AS3 manual. Anyways I tried to help below, let me know if it works correctly... – VC.One Nov 24 '16 at 03:41
1 Answers
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
.
Read the Adobe guide here : Working with File objects in AIR
.
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
}
-
Thanks for help me ,,, That was run correctly in mp4 format..!! ,, Your code is need to chose a video to any location,, But I need to play all video any format from a define Video_folder ,,,, not need to rename such video1.mp4 or video2.flv,,, Help please ..Thanks @VC.One – Md. Sohel Rana Nov 24 '16 at 09:07