flv and f4v player
I'm writing On-demand player. This player need to play flv or f4v format videos.
Example: In that vod folder will available 1 video file (that is flv or f4v), I don't know what is that file format.
So first how can i check that the file format flv or f4v?
I'm trying to below like this.But this is not correct & not working. Can you suggest me how can i play or how to know video file extension?
var videoURL:String;
var videoFileName:String = "test";
var f4v:Boolean = true;
var prefix1:String = "mp4";
var prefix2:String = "f4v";
if(f4v == true)
{
videoURL = prefix1 + ":" + videoFileName + "." + prefix2;
trace("F4V OK");
// trace(videoURL);
}
else{
videoURL = videoFileName;
trace("FLV OK");
}
var serverURL:String = "rtmp://192.168.1.5/vod/";
var nConnection:NetConnection;
var ns:NetStream;
var video:Video = new Video();
nConnection = new NetConnection();
nConnection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
nConnection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
nConnection.addEventListener(AsyncErrorEvent.ASYNC_ERROR, ayncErrorHandler);
nConnection.connect(serverURL);
function netStatusHandler(event:NetStatusEvent):void
{
trace(event.info.code);
switch (event.info.code)
{
case "NetConnection.Connect.Success" :
connectStream();
break;
case "NetConnection.Connect.Failed" :
break;
case "NetStream.Play.StreamNotFound" :
trace("Stream not found: ");
break;
case "NetStream.Play.Start" :
trace("Play Started");
break;
case "NetStream.Play.Stop" :
break;
default :
}
}
function connectStream():void
{
ns = new NetStream(nConnection);
ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, ayncErrorHandler);
ns.client = this;
vidDisplay.attachNetStream(ns);
ns.play(videoURL);
vidDisplay.smoothing = true;
}
function securityErrorHandler(event:SecurityErrorEvent):void
{
trace("securityErrorHandler: " + event);
}
function ayncErrorHandler(event: AsyncErrorEvent):void
{
}
