Bài đăng

Apache Log Rotation

On even a moderately busy server, the quantity of information stored in the log files is very large. The access log file typically grows 1 MB or more per 10,000 requests. It will consequently be necessary to periodically rotate the log files by moving or deleting the existing logs. This cannot be done while the server is running, because Apache will continue writing to the old log file as long as it holds the file open. Instead, the server must be restarted after the log files are moved or deleted so that it will open new log files. in httpd.conf, add: CustomLog "|/usr/local/apache/bin/rotatelogs /usr/local/apache/logs/access_log.%Y%m%d 86400 -360" common (changing the path as needed...) where the number 86400 is seconds to rotation (86400 is 24 hours) and -360 is minutes offset from UTC 0 (-360 is for US Central) and comment out any other line beginning with 'CustomLog' this will give you logs, rotated daily, named something like: access_log.20061101 access_log.20061...

Play next movie after FLV movie is complete

if stream is your NetStream class, at some point you need to hook up an onStatus event handler. Code: ****************************************************************** stream.notify = this; stream.onStatus = function( s ) { notify.onStatus( s ); }; ****************************************************************** this being our video "component", the class that contained the NetStream object. Then our onStatus handler was: Code: ****************************************************************** function onStatus( status ) { switch( status.code ) { case "NetStream.Buffer.Empty": onEmpty(); break; case "NetStream.Buffer.Full": onFull(); break; case "NetStream.Buffer.Flush": onFlush(); break; case "NetStream.Play.Start": onStart(); break; case "NetStream.Play.Stop": onStop(); break; case ...

Three things in order to run video flv:

1. Create blank new flash file. Open library, add "New video" object to library, then add it to stage with the instance name "my_video". 2. Create new layer with a multy-line input text field w/ a border that lies above the "blank video object". The instance name of the txt object must be: "status_txt" 3. Add script written below to the first frame of the flash movie. Save flash movie with the name you want + put following FLV file (videoFile.flv) in the same directory where you're going to execute SWF for streaming. ****************************Code************************************ status_txt.text += "initialize streaming engine" + newline; // Create a NetConnection object var netConn:NetConnection = new NetConnection(); status_txt.text += "creating net connection object..." + newline; // Create a local streaming connection netConn.connect(null); var netStreamStatus = ""; var videoStatus = "loading";...

NetStream.Play.Stop & NetStream.Buffer.Flush

var nc:NetConnection = new NetConnection(); nc.connect(null); var ns:NetStream = new NetStream(nc); video.attachNetStream(ns); ns.play("video1.flv"); ns.addEventListener(NetStatusEvent.NET_STATUS, statusHandler); function statusHandler(e:NetStatusEvent):void { trace(e.info.code); switch(e.info.code) { case "NetStream.Play.Stop": break; case "NetStream.Buffer.Flush": break; } }

Using metadata to detect end of the movie and then loop

Beginning with FLV version 1.1, Macromedia has added a metadata section into a FLV file. The metadata contains the duration of the FLV, among other things. We can use the duration information to check whether a movie has reached the end of playback. Note that not all FLV files have metadata (you will need to use software that supports metadata to create the FLV). We can retrieve the duration information by using the following code (frame 1 of the main timeline of the sample movie): myStream.onMetaData = function(obj) { myStreamDuration=obj.duration; trace("metadata duration="+myStreamDuration); } If the FLV has metadata, the code snippet above will show the duration of the FLV. You can use the Flix Pro 4 FLV to SWF Converter to check for the presence of metadata – if the FLV has no metadata, Flix will show: “[Flv has no metadata]”. If your FLV does not have metadata information, it is recommended that you re-encode the FLV with programs that supports metadata, such as Flix Pr...

Using the onStatus event handler to detect the end of the FLV playback and then loop

onStatus is a method of the NetStream class. To check for the end of FLV playback, we can override it. You can view the implementation of this method by examining the onStatus function on frame 1 of the main timeline of the sample movie. myStream.onStatus = function(info){ trace("info="+info.code); if (info.code == "NetStream.Play.Stop"){ // Set flag, we will need to wait for // "NetStream.Buffer.Empty" before // actually restarting the movie. stopped=true; } if (info.code == "NetStream.Buffer.Empty"){ // At this point, the movie has stopped, and // the buffer is empty. // We're ready to restart the movie. if (stopped){ myStream.seek(0) myStream.play(videoUrl); stopped=false; }}} Here we need to check if the event being sent is NetStream.Play.Stop . When you receive NetStream.Play.Stop , it means that the movie has stopped playing. Note however, because Flv playback has a tendency to freeze when you start a movie without waiting for the playb...

Using System.onStatus

Using System.onStatus Usage System.onStatus = function(InfoObject:Object) { // your statements } Description Event handler: provides a super event handler for certain objects. The LocalConnection, NetStream, and SharedObject classes provide an onStatus event handler that uses an information object for providing information, status, or error messages. To respond to this event handler, you must create a function to process the information object, and you must know the format and contents of the returned information object. In addition to these specific onStatus methods, Flash also provides a super function called System.onStatus, which serves as a secondary error message handler. If an instance of the LocalConnection, NetStream, or SharedObject class passes an information object with a level property of "error", but you have not defined an onStatus function for that particular instance, then Flash uses the function you define for System.onStatus instead. Note: The Camera and...