![]() |
![]() |
There is not much that I like more than music and so I am always looking at new players. I ended up stumbling across one named MusikCube and I have been rather impressed with it so far. What I like most about it is that unlike other similar programs this one has built in functionality for tracking your play history with your website. The program provides access to php $_GET variables passed in a url.
I did not find many contributions regarding this though and I did not find any example code for any language so I decided to write a script in php that will track your tracks as they are played and store all the info to a MySQL database. The script then allows you to view the (x) most recent tracks played in xml format. I found a quick little example on php.net for parsing xml that I modified to display the track information in your website in your sidebar or wherever you decide.
First if you have not already, go download and install the MusikCube player.
Next download our example script and upload both included files to your server.
Open played.php and edit the $config array with values to reflect your setting options for database and
tracks to show. After that is done save the file and close it. Open example.php and set $now_playing_uri
to http://yourdomain.com/played.php were yourdomain.com is the name of your domain.
Start up MusikCube and get listening
As you listen the database will update with the tracks. When you load the example.php in your browser
you will see the recent tracks you have listened to.
TODO:
Modify the code in example.php to suit your needs and incorporate into your site.
You may also want to set up a cron or something to export this data since if you are like
me the player will never stop and that accumulates some serious amounts of data.
You could modify the played.php to output all records from a date until a date and then save
it so you could later use the xml to output statistics for how many times a specific track has been played.
See below for an example of the script in action
Download MusikCube Now Playing PHP Script