As i get so much inspiration and help from this forum, i would like to share the little bits and bytes i produce with you all.
We often produce handmade playlist as we got special rules for our music, this might result in some subjective decisions when selecting titles and some might be played to often and some never.
Here is a first test version of what i’m doing currently, all further improvements are most likely just for our spezial need, so i post just the core functionality.
First I use a typical NotificationScript to send infos to a php script(source is just to see which computer send the info).
[code]procedure OnPlayerStart(PlayerControl: IPlayerControl; Item: IPlaylistItem);
begin
HTTPGetAsync(‘http://192.168.0.115/mairlistlog/log.php?source=MR1&title=’ + Item.GetTitle + ‘&artist=’ + Item.GetArtist );
end;
begin
end.[/code]
The server saves the info to a db:
[code]<?
// db stuff
include(“config.php”);
// convert get values
$source=$_GET[source];
$filename=$_GET[filename];
$artist=$_GET[artist];
$title=$_GET[title];
// write to db
mysql_query(“insert into logging (source,artist,title) values (’$source’,’$artist’,’$title’)”);
?>[/code]
Now when the new playlist is put together, the following NotificationScript takes action:
[code]procedure OnStartup;
begin
EnableTimer;
SetTimerInterval(5000);
end;
procedure OnTimer;
var artist,title,info: String;
i: integer;
begin
for i := 0 to CurrentPlaylist.GetCount - 1 do
if copy(CurrentPlaylist.GetItem(i).GetComment, 1, 7) <> ‘Checked’ then begin
title := CurrentPlaylist.GetItem(i).GetTitle;
artist := CurrentPlaylist.GetItem(i).GetArtist;
info := HTTPGet(‘http://192.168.0.115/mairlistlog/check.php?artist=’ + artist + ‘&title=’ + title);
CurrentPlaylist.GetItem(i).SetComment('Checked ’ + info);
end;
end;
begin
end.[/code]
It is getting infos from this php script:
[code]<?
//db connection stuff
include(“config.php”);
// convert GET values
$artist=$_GET[artist];
$title=$_GET[title];
//sql query: “order by playdate desc” to get latest “playdate” in first row
$q1=mysql_query(“select * from logging where artist=’$artist’ and title=’$title’ order by playdate desc”);
// get number of results, they equal the
$num=mysql_num_rows($q1);
//get single row to know the last playdate
$a1=mysql_fetch_array($q1);
// return the info
echo $num.’ mal, zuletzt: '.$a1[playdate];
?>[/code]
Now every 5 seconds the script checks how often and when last time the title that hasn’t been checked was played and writes the info into the comment row.
This is nowhere perfect, I just wanted to share some ideas and work in progress with you all.