You Are Here Home > September 2008

September 2008

Red5 flash server problems; impossible to get it working

I worked 2 full days to get Red5 0.7.0 working with custom applications but I had no luck.

I couldn’t even get the tutorials written by Red5 developers working, it doesn’t have proper documentation either so it was a real nightmare.
So many other people have these problems too and there seem to be no answer to these problems.

So here is what I did, I installed Red5 0.6.2 and voila! it worked, all the tutorials worked and all the examples worked too!

I’m not a Java guru and I’m glad I’m not, it looks really huge and complicated, it doesn’t look fun to program in at all. I’m sure so many people like it very much but I really think even C is nicer than Java.
For example, to make an even “Hello World” Red5 application you have to make ~5 folders, 4 XML files, 1 Java class, compile your class, upload it to your server and restart Red5!!!

Update:
Funny, I kind of started liking Java :)

Red5 flash server problems; impossible to get it working
Comments (0)   Filed under: Actionscript, Annoying Stuff, Flash   Posted by: Codehead on September 29, 2008

service X does not support chkconfig

Here is how to fix this:

(Assume the name of my script is myscript)

1 – Copy your script into /etc/init.d folder
2 – cd /etc/init.d
3 – chmod +x myscript
4 – Add these lines, including #, right after #!/bin/bash or #!/bin/sh:

# chkconfig: 2345 95 20
# description: Some description
# What your script does (not sure if this is necessary though)
# processname: myscript

5 – chkconfig –level 2345 myscript on

service X does not support chkconfig
Comments (11)   Filed under: General, Server   Posted by: Codehead on September 28, 2008

NetStream.publish Actionscript 3, recording with the best quality

After some time of working on this I found that with the following code, I could get the best quality when recording videos with Flash:

camera.setMode(300, 240, 30);
// camera.setKeyFrameInterval(CAMERA_KEY_FRAME_INTERVAL); /* Comment this out */
camera.setQuality(0, 0);

Funny, with 15 frames per second, there was a lot of problems, but 30 frames per second fixed all the issues for me.

Please do let me know if you have a better solution :)

NetStream.publish Actionscript 3, recording with the best quality
Comments (2)   Filed under: Actionscript, Flash   Posted by: Codehead on September 26, 2008

Bill Gates in Doom

I know many of you probably know about this but here is the video for those who don’t:

http://en.wikipedia.org/wiki/Doom_(video_game)#Release_and_later_history

Bill Gates in Doom
Comments (0)   Filed under: Fun, General, Hobbies   Posted by: Codehead on September 25, 2008

Detecting the end of FLV stream in Actionscript 3, part 2

Read this post first:
http://blog.code-head.com/detecting-the-end-of-flv-stream-in-actionscript-3

Funny today, I get the events in reverse order:

NetStream.Buffer.Empty
NetStream.Buffer.Flush

Yesterday it was:

NetStream.Buffer.Flush
NetStream.Buffer.Empty

I will find the solution though ;)

Detecting the end of FLV stream in Actionscript 3, part 2
Comments (4)   Filed under: Actionscript, Annoying Stuff, Flash   Posted by: Codehead on September 24, 2008

Detecting the end of FLV stream in Actionscript 3

There is an issue with this post, read it and then read this:
http://blog.code-head.com/detecting-the-end-of-flv-stream-in-actionscript-3-part-2

This is also one of those things that I couldn’t really find a real solution to online, so with some tests and experiments, I came up with this solution which I’m not sure if it’s the best solution.

First you will need to attach an event to your incoming stream, assuming your stream is clientStream:

/* ... */
clientStream = new NetStream(serverConnection);
clientStream.addEventListener(NetStatusEvent.NET_STATUS, PlayerStatusHandler);

Then you will need a member variable or a variable in the global scope to keep the latest status:

var playerLastEvent:String = new String();

Now the PlayerStatusHandler which again, I don’t think it’s very pretty:

function PlayerStatusHandler(event:NetStatusEvent) {
	if (playerLastEvent == "NetStream.Buffer.Flush" &&
		event.info.code == "NetStream.Buffer.Empty") { /* Stopped */
		StopPlayback(event); /* Or any other thing you want to do */
	} else if (playerLastEvent == "NetStream.Buffer.Flush" &&
			   event.info.code != "NetStream.Buffer.Empty")
		playerLastEvent = ""; /* Sometimes it throws the Flush event */
	else if (event.info.code == "NetStream.Buffer.Flush")
		playerLastEvent = "NetStream.Buffer.Flush";
}

So as you can see, we are looking for the Flush event that is followed by an Empty event.

This is just tested on my connection and I don’t really know how this works on slow connections, where the buffer is empty often but maybe you can tell me :)

I wish there was an event to show the real end of the stream.

Detecting the end of FLV stream in Actionscript 3
Comments (5)   Filed under: Actionscript, Flash   Posted by: Codehead on

Internet Explorer 7 and viruses

On this page:
http://www.microsoft.com/windows/products/winfamily/ie/default.mspx

It says “See how it helps to protect you from viruses, spyware, and other risks, plus more easily find the information you need.”.

Do you know how? It’s a virus itself!
Just kidding :)

Internet Explorer 7 and viruses
Comments (0)   Filed under: Annoying Stuff, Web Browsers   Posted by: Codehead on September 23, 2008

How to show a microphone activity indicator in Actionscript 3

Here is what I did, first setup a timer:

var micDelay:uint	= 100;
var micRepeat:uint	= 0; /* Run forever */
var micTimer:Timer = new Timer(micDelay, micRepeat);

And then tell it to call our function every 100 milliseconds:

micTimer.addEventListener(TimerEvent.TIMER, ShowMicActivity);

Then the function:

var min:Microphone = new Microphone();
var micActivityIndicator:Shape = new Shape();
function ShowMicActivity(e:TimerEvent):void {
             var h:int = 0;
             var y:int = 0;
	if (mic.activityLevel > 0) {
		h = mic.activityLevel;
		y = 150 - mic.activityLevel;
	} else {
		h = 5;
		y = 150 - 5;
	}
	micActivityIndicator.graphics.clear();
	micActivityIndicator.graphics.beginFill(0x000000);
	micActivityIndicator.graphics.drawRect(0, y, 10, h);
	micActivityIndicator.graphics.endFill();
}

I hope this helps someone, I couldn’t find anything online.

How to show a microphone activity indicator in Actionscript 3
Comments (3)   Filed under: Actionscript, Flash   Posted by: Codehead on

Cursor hand when mouse over images, Actionscript 3-Flash

Funny, I couldn’t find the answer to this anywhere, either the answers are unrelated or they are overly complicated. So here is what I did:

         var imageLoader:Loader     = new Loader();
	imageLoader.load(new URLRequest("path to your image/some image.png"));
	var button:Sprite    = new Sprite();
	button.addChild(imageLoader);
	button.buttonMode    = true;
	button.useHandCursor = true;
	addChild(button);

THAT’S IT!!!

UPDATE:
There is a useful comment bellow by Dan and I thought I should include it in this post so it’s easier for everyone to get the info:

Dan:
To get it to work with a Movieclip you need to set the movieclip as button mode true.

If its the entire stage that needs the hand icon you can add to your script layer.

myMc.buttonMode = true;
myMc.useHandCursor = true;

I use it with an Event listener to only use hand cursor on specific movieclips.

myMc.addEventListener(MouseEvent.ROLL_OVER,myMcOver);
 
function myMcOver (e:MouseEvent):void {
   myMc.buttonMode = true;
   myMc.useHandCursor = true;
}
Cursor hand when mouse over images, Actionscript 3-Flash
Comments (17)   Filed under: Actionscript, Flash   Posted by: Codehead on September 21, 2008

PHP Script for recursively deleting a folder and all of its contents, subfolders and files

<?php
 
	set_time_limit(900);
 
	delete_folder(dirname(__FILE__) .'/');
 
	function delete_folder($folder) {
		$folder_contents = get_folder_contents($folder);
		if ($folder_contents) {
			foreach ($folder_contents as $__content) {
				// echo $__content['item'] .'<br />';
				if (is_dir($__content['item']))
					delete_folder($__content['item']);
				else
					unlink($__content['item']);
			}
		}
		rmdir($folder);
	}
 
	function get_folder_contents($folder) {
		if( !is_dir($folder) ) {
			return false;
		}
		$return_array = array();
		$count		  = 0;
		if( $dh = opendir($folder) ) {
			while( ($file = readdir($dh)) !== false ) {
				if( $file == '.' || $file == '..' ) continue;
				$return_array[$count]['item']	= $folder .$file .(is_dir($folder .$file) ? DIRECTORY_SEPARATOR : '');
 
				$count++;
			}
			closedir($dh);
		}
		return $return_array;
	}
 
?>

Put it *inside* the folder that you want to delete and run it.
Be very careful when using this code, I warned you! Don’t use this if you don’t know any PHP.

PHP Script for recursively deleting a folder and all of its contents, subfolders and files
Comments (3)   Filed under: PHP, Server   Posted by: Codehead on September 20, 2008
Older Posts »