X-Now-Playing with AMIP include

From 40tude Dialog Wiki

X-Now-Playing with AMIP (Include-File)

With this little script done by Ray you are able to place the X-Now-Playing-Header to your articles. You will find AMIP here. There are tons of other Winamp-Plugins doing the same (write the actual played song & artist to a file). Take a look at winamp.com to find other plugins.


Install & Setup the script

Please note that this script is an include-file!. You have to copy the following script inside a new custom script (for example "XNowPlaying_include") and safe it. Please don't compile this custom script! After that you have to add the following lines to your OnBeforeSending-Script:

uses Textfile;
{$I XNowPlaying_include.ds}

and

XNowPlaying_with_AMIP ( Message );

This may look like this:

program OnBeforeSendingMessage;
uses Textfile;
{$I XNowPlaying_include.ds}

function OnBeforeSendingMessage(var Message: TStringlist; Servername: string; IsEmail: boolean):boolean;
begin
  result:=true;

  XNowPlaying_with_AMIP ( Message );

  //possibly some other calls to scripts

end;

begin
end.

It is imperative that the "uses ...;" line is directly beneath the first line, "program ...;", otherwise your script will not compile. If you already have a "uses ...;" statement in your OnBeforeSending Script, simply add the term "Textfile, " to it. The line could look like this;

uses Textfile, Forms, StdCtrls;

Just compile this OnBeforeSending-Script now to get your include-file to work. The setup of the script is shown inside the script. Please take a look at this to customize the script to your own fits. Please note that whenever you reconfigure the X-Now-Playing custom script, you have to recompile the OnBeforeSending-Script to apply the changes.


Setup in the script:
If you want to change the path to your winamp signaturefile you have to edit the line below inside the include-file (custom script).

path := 'c:\programme\winamp5\plugins\np\winamp_sig.txt';

procedure Init_XNowPlaying_with_AMIP ( var path : String
);

begin

//  ----------------------------------------------------
//  Configuration settings
//  ----------------------------------------------------

   // X-Now-Playing with AMIP (by Ray) (Tested with 2.0.6.71)
   // Visit http://amip.tools-for.net/ for further information.
   // Enable "Mail Integration" in AMIP and specify a path for the textfile
   // that will hold the song information. Make sure the path constant in this
   // script points to the same file.

   // Path for X-Now-Playing with AMIP
    path := 'c:\programme\winamp5\plugins\np\winamp_sig.txt'; //should reflect your configuration

//  ----------------------------------------------------
//  End of configuration settings
//  ---------------------------------------------------- 

end;

   // --------------------------------------------------------------- //
   // ----  No user maintainable parts below this line -------------- //
   // --------------------------------------------------------------- //

procedure XNowPlaying_with_AMIP(var Message: TStringlist);
var
  fi   : Textfile;
  st   : string;
  path : String;
  i    : integer;
  XNP  : boolean;
  
begin
   i := 0;
   XNP := false;
   while message[i] <> '' do begin
      if copy (message[i], 1, 15) = 'X-Now-Playing: ' then
         XNP := true;
      i := i + 1;   
   end;    // while  
   If not XNP then begin       
      Init_XNowPlaying_with_AMIP ( path );
      if FileExists(path) then begin
         AssignFile (fi,path);
         Reset(fi);
         TextReadln (fi,st);
         CloseFile (fi);
         message.insert (1, 'X-Now-Playing: ' + st);
      end; // if
   end; // if
end; // XNowPlaying_with_AMIP

René Fischer