Hit counter for streamed sound

How can I make a visible hit counter for sound streams, not page hits? My sounds buttons currently use the mysound/loadsound action to stream external mp3. How can I make a visible counter to keep a tab of how many times music is streamed?

thanks in advance for your reply
ken

With what? asp? php? perl? …etc?

php is the only one i’m familiar with so I guess that

ok…It’s just like every other counter: flash calls a php file which will open a txt file, increase the number in it and write it to the same file and if needed returns the number. The only difference is that the php needs to be called when the sound starts playing.


$count = file_get_contents("count.txt");
$count++;
$fp = fopen("count.txt", "w+");
fwrite($fp, $count);
fclose($fp);

Now you should make a text file named “count.txt” and type a number ‘0’ in it (I’m not sure if this is necessary but just in case) and change it’s permissions to 777 when you upload the file to your server.
Now in flash you need to trigger the php file once the sound starts loading.
So for the buttons that should load a sound add this action:


loadVariablesNum("counter.php", 0);

Just make sure that the file in the quotes is the php file…

PS! There should be a hit counter tute coming soon.

I did everything you specified first to test it. I added the load variable code to my flash button, made a counter.php file and a count.txt file (with 0). But when I test it by uploading everything, opening a new browser and pressing play, I check back with my web admin and in the count.txt file, the value is still 0. I changed the permissiom too. What might be doing wrong?

In addition, I wanted that number to be visible on the page where users press play

take a look at this page and see where it says total plays, I am trying to make a visible counter right under it.

www.aconeinc.com/beats.htm

k… run the php file in your browser (on the server, not locally) and see if it gives you any error messages…

to see the count number in flash add this line at the end of your php file:

print “&count=”.$count;

the variable name of your dynamic textbox here should be “count” (you can change it to whatever but make sure you change te php file too)

and now to make sure flash displays the count correctly make sure the paths are correct (loadVariablesNum action is in the same movieclip where your dynamic textfile is).