AMIP SDK bindings for PHP 5.1.x & PHP 5.2.x in the form of native win32 
PHP extension. (c) Serge Baranov, 2007.

Package includes php_amip.dll (for PHP 5.2.x) and php_amip_514.dll
for PHP 5.1.x (compiled with PHP 5.1.4).

amip.php is the script loading the extension, just include it in your
script to use.

shownp.php is a sample illustrating how to get and format now playing
song information using this extension from AMIP.

===========================================================================
This extension allows you to work with AMIP from your PHP scripts.
Load it in your php.ini or inside the script, like:

  dl('php_amip.dll');

However, it's recommended to just include the wrapper script, like:

  include('amip.php');

and then use API as usual. Note that ac.dll must be in PATH or in the current
directory so that server/PHP can load it. ac.dll is required for php_amip.dll
to load.

For the API documentation see samples and comments in ac.h.


===========================================================================
Differences in PHP AMIP API:

There are importand differences, functions in ac.h that return strings
to the passed buffer variable in PHP should be used without the buffer,

C++:

  char buff[2048]
  ac_getDestHost(buff);

PHP:

  $host = ac_getDestHost();

ac_get_title() function in PHP returns 2 values in array, first element
is the result, the second is the title. Should be used like this:

  list($res, $title) = ac_get_title(0);

You MUST check that $res == 1 before doing anything with the $title:

  if($res == 1) echo 'title: ' . $title . "\n";
  
The same applies to ac_eval and ac_format functions.


Other functions can be used like in C/C++.

===========================================================================
Experimental callback support is available. However, you should avoid using
it since PHP does't support multithreading while callback functions are
called into another thread. This can cause PHP crash under some conditions.

The following code illustrates how to use PHP callbacks:

  $changed = false;
  
  function event_callback($e) {
    echo "playlist has changed\n";
    $changed = true;
  }

  ac_init();

  ac_register_evt_callback('event_callback');
  ac_add_event_listener('127.0.0.1', 60334, 5000, AC_EVT_PLCHANGE);

This cannot be used in the server environment, as the script execution will 
stop here.

If you are using it in some scripting environment like Miranda Scripting
Plug-In (http://addons.miranda-im.org/details.php?action=viewfile&id=1584)
or command line execution, or similar, when script doesn't finish and stays
in the memory, this should work. In CLI PHP you can loop at the end:

  while(!$changed) {
    sleep(1);
  }

The script will finish when event is received.
