Get the stream (pls) of a streamtheworld radio

April 12th, 2010

If like me you are listening to some webradios, you probably have faced this problem : a lot of radios are broadcasting over the web via an embedded flash player to force you to go on their website to be able to listen to it.

So if you want to get the actual audio stream URL (pls or m3u), the widely used solution is to take a look at the requests that the player is sending to its server (with the NET tab of Firebug on Firefox per example).
But it sometimes happens that the URL you get is not an audio stream but a flash file with a buffering system so in this case, you cannot use it on your favorite webradio player (or on your N900 like me :p).

So, let’s get to the point of this post : if the radio you want is a streamtheworld stream (like the radio I wanted to get : Radio CKOI), I’ve got a really simple solution for you :
First of all, use Firebug on Firefox to see the requests that the player is doing and try to locate a request that looks like : http://38.100.101.69/CKOIFMAAC?streamtheworld_user=1&nobuf=1271075550431.
Once that you have done so, you just have to use the stream ID this URL provided you : CKOIFMAAC in this example.

The URL you are looking for is : http://provisioning.streamtheworld.com/pls/{theIDofTheStream}.pls

Decompile a SWF file on Windows

April 12th, 2010

I have recently discovered a great tool to decompile SWF animations (I needed a tool to extract the animation of a game to add design to one of my school projects).

So the only free solution I have found is called SWFTools. But the problems are that you don’t have any GUI for the tools that it provides so you have to do all the operations with the console and that you cannot extract all the objects at a time : you have to specify the ID of the object you want to extract!

So I have written a little batch script to extract all the objects automatically :

First of all, you have to create a sub-folder in your SWFTools folder (“badger” in this example).
Then copy the swf file you want to decompile in your SWFTools folder (“badger.swf” in this example).
Then decide how many objects you want to try to extract (200 in this example), it depends on the size of the swf file. The bigger the number the longer it will take.

Then create a bat file in your SWFTools folder, edit it with notepad, copy/paste the following script in it and finally replace the values.

:: To extract all the elements of the animation
FOR /L %%i IN (0,1,200) DO (
swfextract.exe -i %%i -o badger/%%i.swf badger.swf
)

:: To ajust the dimentions of the windows
FOR /L %%i IN (0,1,200) DO (
swfbbox.exe -o badger/%%i.swf -Oe badger/%%i.swf
)

Once you have extracted the object you were looking for (123.swf in this example), if you want to extract the png images of the different frames, copy paste it to the SWFTools folder and execute the following script.

:: To extract all the images of an animation
FOR /L %%i IN (0,1,50) DO (
swfextract.exe -p %%i -o badger/%%i.png 123.swf
)

Else, if you want to extract the vectors from the swf you have isolated, use Flash Exploit

New Theme : The Power Of The Water

February 9th, 2010

Hey folks!
My new theme The Power Of The Water finally got accepted by the WordPress Team !

To download it, simply go to http://wordpress.org/extend/themes/the-power-of-the-water.

I hope you’ll like it! If you don’t, please write your comments on this post.

Enjoy ;)

SVN problems for Linkedin Resume

January 20th, 2010

I’ve completely messed up the SVN of linkedin resume today between 11:30 UTC and 12:30 UTC, I’m realy sorry for those who tried to download it during this period but it was for a good reason:
Now, that I’ve all fixed up, you can download older versions of the plugin (1.8 for the moment but soon all the old versions!).
That’s a good news for those who are experiencing some troubles with the new version.

JQuery usecase : Moving a fish in the back of a web page

January 19th, 2010

The friend I’ve integrated the design for (http://www.stratewaterdesigners.com) recently asked me to add a fish that would move on the background of the website randomly. Even if I don’t really like JQuery, because it is the default WordPress framework I made with it.

So, here are the problems I’ve been confronted to :

How to make the fish move randomly?

To achieve that, I have used the JQuery method animate that I’ve called in an endless recursion to make the fish move 100px to the left or to the right and adding a random multiplicative to the top position of the fish

How to make the fish go under all the elements of the page?

To do that, I’ve used the CSS properrty z-index, it allows us to put one div in front of an other.But be careful, it only works for positioned elements (position:relative|absolute). So I’ve set all the positioned element of my page with a z-index of 10 and assigned my fish a z-index of 1.

How to make the fish go the other way around?

This what took me the longest : First, I check that the fish is at the right position, then I call the animate function to change at the same time three CSS values : ‘left’, ‘background-position’,'width’ to make the fish kind of rotate :p. Also, to avoid any loading time I’ve used a css trick : an image with my two fishes (the fish looking to the left and the one looking to the right) that is two times bigger than its container, so to swap between the two, I just have to change the background image position !

So now, the script : ( demo )

	var $j = jQuery.noConflict();
	$j(function(){
		var maurice = $j('< div>< /div>');
		var topPos = 200+Math.floor(Math.random() * (document.height-200));
		maurice.css({'position':'absolute','left':'-100px','top':topPos,'width':'100px','height':'70px','background':'url(/img/fish.png) no-repeat','z-index':'1'});
		var replaceleft = function(){
			maurice.css({'backgroundPosition':'-50px 0'});
			maurice.animate({'backgroundPosition':'0px 0%', 'width':'100px', 'left':0},200, "swing", callback);
		}
		var swapleft = function(){
			maurice.animate({'backgroundPosition':'-50px -70px', 'width':0, 'left':50},200, "swing", replaceleft);
		}
		var moveLeft = function(){
			var topMove = 50-Math.floor(Math.random() * 100);
			var newTopPos = parseInt(maurice.css('top'))+topMove;
			while(newTopPos<0){
				topMove = Math.floor(Math.random() * 100);
 				newTopPos = parseInt(maurice.css('top'))+topMove;
 			}
			while(newTopPos>document.height){
				topMove = 0-Math.floor(Math.random() * 100);
				newTopPos = parseInt(maurice.css('top'))+topMove;
			}
			if(100 < parseInt(maurice.css('left')))	maurice.animate({'left':parseInt(maurice.css('left'))-100,'top':newTopPos},1000, "swing", moveLeft);
			else maurice.animate({'left':0},500, "swing", swapleft);
		}
		var replacefish = function(){
			maurice.css({'backgroundPosition':'-50px -70px'});
			maurice.animate({'backgroundPosition':'0px 100%', 'width':'100px', 'left':screen.width-140},200, "swing", moveLeft);
		}
		var swapfish = function(){
			maurice.animate({'backgroundPosition':'-50px 0', 'width':0, 'left':screen.width-90},200, "swing", replacefish);
		}
		var callback = function(){
			var topMove = 50-Math.floor(Math.random() * 100);
			var newTopPos = parseInt(maurice.css('top'))+topMove;

			while(newTopPos<0){
 				topMove = Math.floor(Math.random() * 100);
 				newTopPos = parseInt(maurice.css('top'))+topMove;
 			}
			while(newTopPos>document.height){
				topMove = 0-Math.floor(Math.random() * 100);
				newTopPos = parseInt(maurice.css('top'))+topMove;
			}
			if(parseInt(maurice.css('left'))