Now Playing Notification Script Not Working

I have just upgraded to the latest 3.1.1 from 3.0.14

I have a notification script that writes a file to upload to the web to display now playing.
It was working fine in 3.0.14 but now doesn’t write to a file.
It shows that it has loaded the notification script with no errors when the first player starts.

The code I am using is below…


{-------------------------------------------------------------------------------
  NotPlayingHTML.mls - Notification Script for mAirList

  Writes a HTML page with the currently playing sing.

  Author: Torben Weibert <tw@mAirList.com>
  Date: 2010-01-19

  See http://www.mAirList.com for further information.
-------------------------------------------------------------------------------}

procedure OnPlayerStart(PlaylistIndex: integer; PlayerIndex: integer; Item: IPlaylistItem);
var
  sl: TStringList;
begin
  sl := TStringList.Create;
  try
    sl.Add('<html>');
    sl.Add('<title>Now Playing</title>');
    sl.Add('<META HTTP-EQUIV=REFRESH CONTENT=10>');
    sl.Add('<META HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHE>');
    sl.Add('<body topmargin=0 leftmargin=1 background=nowplaybarbag_26x23>');
    sl.Add('</center>');
    sl.Add('<font face=arial size=2 color=#ffffff><b>');
    sl.Add(' ' + Item.GetArtistsString + ' - ' + Item.GetTitle + ' ');
    sl.Add('</b></body></html>');
    sl.SaveToFile('c:\nowplaying\nowplaying.php');
  finally
    sl.Free;
  end;
end;

begin
end.

Also I have just noticed, despite the conifg saying ‘Start in On Air mode’, it is starting in Off Air mode.

Can you please try to insert the following line before “sl := TStringList.Create” to verify that the procedure is actually invoked?

SystemLog('It works.');

The message should appear in the system log, that is, in the status bar in the main window, and in the dialog that appears when you double-click the status bar.

Can anybody reproduce the “start in on air mode” bug? Because it works for me.

I am away from the office at the moment so will try this later when I get back.

I have noticed that is is updating the file now, but the information is about 30 minutes out of date.
There seems to be a buffer of information that it is reading from 30 minutes later?

Hm, actually the file should be written with the most recent data right away.

When you insert the SystemLog line, check if the “it works” message appears immediately. If it is also delayed, which I doubt, then there’s something wrong with the script processing. I will be able to send you a special debug version in that case that will help to sort the problem out.

Hi Torben,

Have added the line to the script as follows…

{-------------------------------------------------------------------------------
  NotPlayingHTML.mls - Notification Script for mAirList

  Writes a HTML page with the currently playing sing.

  Author: Torben Weibert <tw@mAirList.com>
  Date: 2010-01-19

  See http://www.mAirList.com for further information.
-------------------------------------------------------------------------------}

procedure OnPlayerStart(PlaylistIndex: integer; PlayerIndex: integer; Item: IPlaylistItem);
var
  sl: TStringList;
begin
SystemLog('It works.');
  sl := TStringList.Create;
  try
    sl.Add('<html>');
    sl.Add('<title>Now Playing</title>');
    sl.Add('<META HTTP-EQUIV=REFRESH CONTENT=10>');
    sl.Add('<META HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHE>');
    sl.Add('<body topmargin=0 leftmargin=1 background=nowplaybarbag_26x23>');
    sl.Add('</center>');
    sl.Add('<font face=arial size=2 color=#ffffff><b>');
    sl.Add(' ' + Item.GetArtistsString + ' - ' + Item.GetTitle + ' ');
    sl.Add('</b></body></html>');
    sl.SaveToFile('c:\nowplaying\nowplaying.php');
  finally
    sl.Free;
  end;
end;

begin
end.

It does not appear to write anything to the log except that it has loaded the script.
Also the ‘Off Air’ mode at start up seems to change after 30 minutes and then the system appears as ‘On Air’.

Have opted back to running 3.0 and now playing scripts and on air at start up seem to be fine.

Bizzare… Hope this makes sense. :slight_smile:

Chris.

Hmm … let’s just check: you have added your script (and its correct current location) to the Notification Scripts list in Config, yes?

If your new script is being executed it will definitely display the text It Works. in the mAirList status bar each time it executes, and will be added as an Info entry to the System Log.

If that isn’t happening, one likely cause is that the Notification Scripts list in Config is ‘pointing’ to a different copy of the file, most probably one in a different folder.

So, can you please confirm that (check the path CAREFULLY), and then let us know? Thanks.

BFN
CAD

You may wish to remove “try” and “finally” from your script.

No, please keep the “try” and “finally”. It makes sure that the memory used for the TStringList object is released even when one of the operations in between fails, e.g. when the file cannot be written (invalid folder name, no disk space, no permissions).

Oh right - I assumed they were random words that somebody had put into the script as an aid :slight_smile:

It’s so strange.

This is th path for the script… C:\Program Files\mAirList 3.1\scripts\notification\NowPlayingHTML.mls
Opened the config window and it is there in Notification Scrips with the following path… C:\Program Files\mAirList 3.1\scripts\notification\NowPlayingHTML.mls
They are the same so it is reading the correct script.

I have attached a copy of the log file so you can see what it is writing as it runs in automation :slight_smile:

Some interesting results… It only starts running the notification script after another timed event has happened.
The information it is writing to the nowplaying file is not from the current piece of audio, in fact it is the song data from when the playlist started.

Hope this information is helpful.


log.txt (69.9 KB)

Thanks for the information. Looks like the message processing is “stuck” in a way.

Here’s a special debug snapshot: http://www.mairlist.com/download/mAirList/v3.1/debug2/

It will open another window with debugging information, and also write that information to a file named debug-.txt. Please let it run for a few minutes to reproduce the error, and then send the debug text file to info@mairlist.com.

Please also change the SystemLog line in your script to

SystemLog('It works: ' + Item.GetTitle);

This will help measuring the delay between the actual start time of the item, and the time it is processed by the notification script.

Finally, I should mention that writing an HTML file with the current song is also possible with the File log interface when you enable the option “Overwrite this file each time a log entry is written” in the log file configuration. The NowPlayingHTML.mls file dates back to the time when that option wasn’t present yet. Nowadays, I would prefer using the log file mechanism, but I thought it was a good idea to keep the script as an example.

Hi Torben,

I have just run this and got a similar seris of events that you can now look at.
Just sent the email with the files you requested.

Kind Regards
Chris.

Thanks. Haven’t received any e-mail yet though.

Oops,

Appears email was over size limit.
Resending now.

;D

Yes, these debug logs can grow very large :slight_smile:

Analyzing the logs, it seems that the lag is resulting from the OnTheFly database, which is being initialized during startup, which causes a lot of messages sent through the internal messaging system (to which the notification scripts are attached). It seems that the script never manges to catch up later.

First of all, I would recommend to turn the OTF database into a (local) mAirListDB if that makes sense for you. Much more comfortable, and much faster startup.

Second, I have changed the notification script code so that the messages are processed in a separate thread, which should be much faster. This change is included in Build 782 which I just uploaded as a regular snapshot.

http://www.mairlist.com/download/mAirList/v3.1/snapshot/

Please give it a try.

Thank you.

I will give this snapshot a go.
Can you advise in a few lines how to set up this alternative database please?

I am looking to list all the music that is contained within one directory on a network drive.

Chris.

http://wiki.mairlist.com/index.php/mAirListDB_HowTo

Chris: as Torben says, follow those instructions.

If you have a single networked folder for all your music, you need only add one ‘Storage’ (as it is known in mAirListDB), pointing to your one network folder. Note that this will include any subfolders of that folder automatically: you don’t add subfolder as separate Storages.

Hope that helps.

BFN
CAD

Thanks guys,

I appreciate your help with this. I will have a look at that. Seems quite simple.

What’s the easiest way now to generate the now playing info for a website if the notification scripts are a little out dated?

:slight_smile:

Chris

Check Torben’s answer here:
http://forum.mairlist.com/index.php/topic,4720.msg33573.html#msg33573

Basically, you create an ‘extra’ text log file which is overwritten each time a Player starts or stops.
In Config: Logging, Add, Log file, then specify a drive/path/file name (e.g. c:\web\nowplaying.txt) and tick the Overwrite box. Start Entry Format would be (e.g.) %b - %a and Stop Entry Format would be blank.

You then use this file to ‘feed’ your ‘now playing’ process on the Web or wherever. When a Player starts, it will write the title/artist to the text file. You would have to add all the other HTML gubbins some other way. Personally, I use Glenn Delahoy’s AutoFTP program and a JavaScript at the far end to process the text file.

BFN
CAD