PDA

View Full Version : video Class VS videoPlayer Class


EugenR32
08-11-2008, 08:59 AM
Hello,

i have compared the "video" and the "videoPlayer" classes for use
with progressive download and find out, that the videoPlayer class is some kind of "bugy"

I created the folowing the code samples for testing:

Test 1)

1: Creat new project (ActionScript 3)
2: insert this AS3 Code

import flash.events.NetStatusEvent;
import flash.events.SecurityErrorEvent;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.events.Event;


var customClient:Object = new Object();
var videoURL:String = "output.flv";
var stream:NetStream;

var connection:NetConnection = new NetConnection();

// Add Listeners
connection.addEventListener(NetStatusEvent.NET_STA TUS, netStatusHandler);
connection.addEventListener(SecurityErrorEvent.SEC URITY_ERROR, securityErrorHandler);

connection.connect(null);

function netStatusHandler(event:NetStatusEvent):void {

trace("-- function netStatusHandler");

trace("target = " + event.target + " currentTarget = " + event.currentTarget);
switch (event.info.code) {
case "NetConnection.Connect.Success" :
connectStream(NetConnection(event.currentTarget));
break;
}
}

function securityErrorHandler(event:SecurityErrorEvent):voi d {

trace("securityErrorHandler: " + event);
}

function asyncErrorHandler(e:AsyncErrorEvent):void {

trace("asyncErrorHandler: " + e.text);
}
function connectStream(connection:NetConnection):void {

stream = new NetStream(connection);
var video:Video = new Video();

stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
stream.addEventListener(AsyncErrorEvent.ASYNC_ERRO R, asyncErrorHandler);

video.attachNetStream(stream);
video.x = 18;
video.y = 120;
stream.play(videoURL);

addChild(video);

}


3: upload biger FLV Video (50 MB and more) to your Webserver and
change videoURL in the AS3 Code
4: Publish your Project
5: Upload the published Files to your webserver (same folder as FLV Video)
6: start taskmanager / activity monitor
7: open C:\Documents and Setting\\Local Settings\Temp
8: Enter URL to the uploaded HTML File on your Webserver into your Internet Browser

Now look what is happening:
- CPU usage between 5% - 20%
- No Data of the Video is stored in your RAM
- The Video ist stored on your HDD in the Temp folder your opened
There you see a *.tmp file, that has same filesize as your uploaded video (because this tmp file is the video)

-------------------------------------------------------


[U]Test 2)
1: Creat new project (ActionScript 3)
2: insert FLVPlayback Component to the library
3: insert this AS3 Code

import flash.events.NetStatusEvent;
import flash.events.SecurityErrorEvent;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.events.Event;
import fl.video.VideoPlayer;




var customClient:Object = new Object();
var videoURL:String = "output.flv";
var stream:NetStream;

var connection:NetConnection = new NetConnection();

// Add Listeners
connection.addEventListener(NetStatusEvent.NET_STA TUS, netStatusHandler);
connection.addEventListener(SecurityErrorEvent.SEC URITY_ERROR, securityErrorHandler);

connection.connect(null);

function netStatusHandler(event:NetStatusEvent):void {

trace("-- function netStatusHandler");

trace("target = " + event.target + " currentTarget = " + event.currentTarget);
switch (event.info.code) {
case "NetConnection.Connect.Success" :
connectStream(NetConnection(event.currentTarget));
break;
}
}

function securityErrorHandler(event:SecurityErrorEvent):voi d {

trace("securityErrorHandler: " + event);
}

function asyncErrorHandler(e:AsyncErrorEvent):void {

trace("asyncErrorHandler: " + e.text);
}
function connectStream(connection:NetConnection):void {

stream = new NetStream(connection);
var videoPlayer:VideoPlayer = new VideoPlayer(320,240);

stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
stream.addEventListener(AsyncErrorEvent.ASYNC_ERRO R, asyncErrorHandler);

videoPlayer.attachNetStream(stream);
videoPlayer.x = 18;
videoPlayer.y = 120;
videoPlayer.play(videoURL);

addChild(videoPlayer);

}


4: upload biger FLV Video (50 MB and more) to your Webserver and
change videoURL in the AS3 Code
5: Publish your Project
6: Upload the published Files to your webserver (same folder as FLV Video)
7: start taskmanager / activity monitor
8: open C:\Documents and Setting\[user]\Local Settings\Temp
9: Enter URL to the uploaded HTML File on your Webserver into your Internet Browser


Now look what is happening:
- CPU usage between 60% - 80%
- The hole video is loaded pice by pice to your RAM
- The Video ist NOT stored on your HDD in the Temp folder
- imagine you have a 200 MB Video and only 512 MB RAM...
Your system will hang up !

------------------------------------------------

I think this is a important differenze !
Is there a reason for this behavior ?
Was the FLVPlayback Component created like this on purpose ?
Is this a BUG ?

Best Regards
EugenR32