PDA

View Full Version : Progressive Video works when tested from Flash but fails once deployed on server



Gar_Fonz
August 16th, 2008, 08:33 PM
Heres the code that I'm using
var videoURL:URLRequest = new URLRequest("");
var connection:NetConnection;
var stream:NetStream;

function sec(e:IOErrorEvent){
trace(e);
}
var videoX:int = 0;
var videoY:int = 0;
var request:URLRequest = new URLRequest("main.xml");
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, done);
var xml:XML = new XML();
loader.load(request);
var duration:Number =0;
var streamArray:Array = [];
var video:Video = new Video(150, 200);
function done(e:Event){
xml = new XML(loader.data);
for(var i:int = 0; i< xml.video.length(); i++){
videoURL = new URLRequest(xml.video[i].@url.toString());
videoX = xml.video[i].@x;
videoY = xml.video[i].@y;
connection = new NetConnection();
connection.addEventListener(NetStatusEvent.NET_STA TUS, netStatusHandler);
connection.addEventListener(SecurityErrorEvent.SEC URITY_ERROR, securityErrorHandler);
connection.addEventListener(AsyncErrorEvent.ASYNC_ ERROR, async);
connection.addEventListener(IOErrorEvent.IO_ERROR, sec);
video= new Video(150, 200);
connection.connect(null);
}
addEventListener(Event.ENTER_FRAME, loop);
}
var netClient:Object = new Object();
netClient.onCuePoint = onCuePoint;
netClient.onMetaData = onMetaData;
function loop(e:Event){
for(var k:int = 0; k < xml.video.length(); k++){
if(streamArray[k].time >= duration){
streamArray[k].seek(10);
}
}
}
function onCuePoint(info:Object):void
{
trace("cuePoint: time=" + info.time + " name=" + info.name + " type=" + info.type);
}
function onMetaData(info:Object):void
{ duration = (info.duration - 3);
trace("metadata: duration=" + info.duration + " width=" + info.width + " height=" + info.height + " framerate=" + info.framerate);
}

function async(event:AsyncErrorEvent){
trace ("there was an AsyncErrorEvent " +event);
}
function netStatusHandler(event:NetStatusEvent):void {
switch (event.info.code) {
case "NetConnection.Connect.Success":
connectStream();
break;
case "NetStream.Play.StreamNotFound":
trace("Stream not found: " + videoURL);
break;
}
}

function securityErrorHandler(event:SecurityErrorEvent):voi d {
trace("securityErrorHandler: " + event);
}

function connectStream():void {
stream = new NetStream(connection);
streamArray.push(stream);
stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
stream.client = netClient;
video.attachNetStream(stream);
video.x = videoX;
video.y = videoY;
stream.play(videoURL.url);
addChild(video);
}


Just to reiterate, the file works fine when I test it in Flash and as a projector. The video doesn't load when I download the files from my server. I have checked to ensure that all the file paths are correct. Does anybody have any advice or suggestions? I appreciate any help that can be offered.

Gar_Fonz
August 17th, 2008, 05:10 PM
Well I found the problems, and it wasn't with my Actionscript, so this should probably be moved to a different part of the forum, oops.

First of all, the server I'm running is Microsoft server 2003, IIS 6.0. By default, IIS 6.0 does not have the MIME type for .flv, so you have to add it. Instructions to do so are here (http://it.toolbox.com/blogs/rymoore/adding-flv-mime-type-in-iis-4198). The other problems is that parent paths have to be enabled. Information on how to enable that is here (http://support.microsoft.com/kb/332117).