Hi Cad,
Much appreciated for the script.
Right now I have the following script, yet an error popped up in mAirList, line 55 saying it wasn’t happy with AnsiStringReplace. So I removed the ‘Ansi’ and left it as StringReplace, yet it isn’t happy with that either (see attached image).
[code]// Intelligent Now Playing Script v2
// by Charlie Davy
// last modified 16th January 2009
// This script examines each audio item played via a Player and performs a task based upon the track’s length.
// The 3 settings below work for most situations, however you can fine-tune them if you wish.
// The last.fm links work for most artist/groups - it adds a nice touch, I think.
// Update: The OnAir switch is considered within this script, if you are “Off Air”, this script does nothing.
// If you are “On Air”, the script runs as normal. Useful in a multi-studio environment where pre-recorded
// shows may interfer with your live “now playing” display!
// IMPORTANT!! You MUST rename this file to .mls when adding it to mAirListConfig
const
IDENT = 900000000; // 90 seconds
MUSIC = 900000000; // 90 seconds
PRE_REC = 4200000000; // 7 minute
var
sTitle, sArtist: string;
sl: TStringList;
procedure OnPlayerStart(PlayerControl: IPlayerControl; Item: IPlaylistItem);
var sl: TStringList;
begin
if Engine.GetOnAir = False then begin
SystemLog(‘mAirList is in production mode, so no action taken…’);
sl := TStringList.Create;
sl.Add(‘LiveWire Radio’);
sl.SaveToFile(‘C:\Users\Ryan\Documents\HOMEWORK_RADIO\site\nowplaying\nowplaying.php’);
sl.Free;
// If the track is over 7 minutes, assume it’s a pre-recorded programme
end else if (Item.GetDuration > PRE_REC) then begin
sl := TStringList.Create;
sl.Add(‘More music soon’);
sl.SaveToFile(‘C:\Users\Ryan\Documents\nowplaying\nowplaying.php’);
sl.Free;
SystemLog(‘This item is a pre-record or longer than 7 minutes…’);
// If the track is more than 90 seconds, assume it’s a song
end else if (Item.GetDuration > MUSIC) then begin
sTitle := Item.GetTitle;
sArtist := Item.GetArtist;
SystemLog(sArtist + ’ - ’ + sTitle);
sTitle := StringReplace(sTitle, ‘’’’, ‘%27’);
sTitle := StringReplace(sTitle, ‘,’, ‘%2C’);
sArtist := StringReplace(sArtist, ‘’’’, ‘%27’);
sArtist := StringReplace(sArtist, ‘,’, ‘%2C’);
sl := TStringList.Create;
sl.Add(’<?php’);
sl.Add(‘if (!$xmlObj=simplexml_load_file ( "http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=’ + sArtist + ‘&api_key=097a7ab0f5b56a894eb7a25e1c51b0da" )){’);
sl.Add(‘echo “Error reading XML file”;’);
sl.Add(’}’);
sl.Add(‘foreach($xmlObj as $artist){’);
sl.Add(‘echo "Price : " . $artist->name . “
”; ‘);
sl.Add(‘echo "Price : " . $artist->image . “
”;’);
sl.Add(‘echo "Price : " . $artist->bio->summary . “
”;’);
sl.Add(’}’);
sl.Add(’?>’);
sl.SaveToFile(‘C:\Users\Ryan\Documents\HOMEWORK_RADIO\site\nowplaying\artist.php’);
sl.Free;
sl := TStringList.Create;
sl.Add(’<?php’);
sl.Add(‘if (!$xmlObj=simplexml_load_file ( "http://ws.audioscrobbler.com/2.0/?method=track.getinfo&artist=’ + SArtist + ‘&track=’ + STitle+ ‘&api_key=097a7ab0f5b56a894eb7a25e1c51b0da" )){’);
sl.Add(‘echo “Error reading XML file”;’);
sl.Add(’}’);
sl.Add(‘foreach($xmlObj as $track){’);
sl.Add(‘echo "Price : " . $track->name . “
”; ‘);
sl.Add(‘echo "Price : " . $track->wiki->content . “
”; ‘);
sl.Add(’}’);
sl.Add(’?>’);
sl.SaveToFile(‘C:\Users\Ryan\Documents\HOMEWORK_RADIO\site\nowplaying\track.php’);
sl.Free;
sl := TStringList.Create;
sl.Add(’’ + Item.GetArtist + ’ - ’ + Item.GetTitle + ‘’);
sl.SaveToFile(‘C:\Users\Ryan\Documents\HOMEWORK_RADIO\site\nowplaying\nowplaying.php’);
sl.Free;
SystemLog('Now Playing… ’ + Item.GetArtist + ’ - ’ + Item.GetTitle);
end;
end;
begin
end.[/code]
Thanks, Ryan.
