Highlight Audio Types - Solution to Lacksters Request.

Here is the script.

The way I currenty use it is as an Action in the action menu, I put all the audio into my playlist and click the button for the colour magic to appear!

[code] // Highlight Audio Types - Matt Green

// This simple script will colour specially tagged items automatically.
// All you have to do is add a User Defined Property (Name of ‘Type’, value of your choice) to all the audio you wish to auto-colour.
// You can then edit the script below to set your ‘Type’ values and the colour you wish to change it too. You can also change other features
// of the item by adding item.[SetPropertyValue]; between then BEGIN and END within the IF statements.

// A sample of how to add extra items is added below (remember to uncomment if you are going to use it).

VAR
i: integer;
item: IPlaylistItem;

BEGIN
FOR i := 0 to CurrentPlaylist.GetCount - 1 DO

BEGIN
item := CurrentPlaylist.GetItem(i);

IF item.GetUserData.Values['Type'] = 'Ident' THEN BEGIN
	item.SetColored(true);
	item.SetColor($9EE0D3);
END ELSE IF item.GetUserData.Values['Type'] = 'Bed' THEN BEGIN
	item.SetColored(true);
	item.SetColor($EE22AA); 

// END ELSE IF item.GetUserData.Values[‘Type’] = ‘Trail’ THEN BEGIN
// item.SetColored(true);
// item.SetColor($EE22AA);

END;

END;

END.[/code]

Hope this helps someone!

How do you actually set the “type” if your audio?

Thanks.

In the properties of the audio track, add a User Defined Property (Name of ‘Type’, value of your choice) to all the audio you wish to auto-colour.

The value you set for the Type needs to then be in the script so it knows which colour to set.

In other words, Ryan, you need to manually (or with a script) set and save a new User Defined Property (UDP) named Type for each audio item.

Actually, thinking about it … it would be possible to avoid using Type altogether if you write two or three scripts which set the colour of all the items in the current Playlist. For example, one script to set the ‘Ident’ colours, one to set the ‘Bed’ colours, etc.

You would then quickly make a Playlist with (again for example) all your Idents in it, then run the ColourIdents script; empty the Playlist and put all your Beds in it, then run the ColourBeds script; and so on.

BFN
CAD

Hi Cad, as always an excellent idea to speed things up.

Any pointers to a reference site where non programmers like myself can go and lookup the coding to have a go ourselves.

Hopefully, you, Charlie or Matt can come up with such a script but it would still be nice to try for myself.

Kind regards Tony

Definately a good idea instead of going through well over 1000 songs and “type” them all. I would have no clue how to make a script like that in all honesty :-\

Thanks.

Ok, pinching bits of examples posted by Matt and Charlie here is something that should do as asked.

[table][tr][td]// Highlight Audio - Tony Wilding

// This simple script will colour audio files according to you specifications
// Build a playlist of similar audio, i.e. all promos.
// Specify the colour highlight for this type of audio.
// Remember to remove the comment lines.

// Run the script, it worked for me. With a little re-working you should also be able to specify icons.

var
i: integer;

begin
for i := 0 to CurrentPlaylist.GetCount - 1 do

// If EndType is empty, then do it
//if CurrentPlaylist.GetItem(i).GetEndType = ‘’ then

begin

//CurrentPlaylist.GetItem(i).SetColored(true);

//CurrentPlaylist.GetItem(i).SetColor($80FF80);

//CurrentPlaylist.GetItem(i).SaveMMD;

end;
end.[/td][/tr][/table]

Remember to save multiple copies of the script, with a name identifying the colour of the highlight.

Kind regards Tony

It works…but only temporarily…after redragging the audio back into the playlist after refreshing the playlist, it goes back to “no colour”.Thanks.

If the playlist is a basic M3U or you’re re-dragging from the Browser - the new settings should remain, especially as you’ve written them to the MMD data file. If you’re re-loading an MLD, MLP or MLT file - then ALL data is stored within those files - regardless of MMD settings.

This is so that you can pre-produce a playlist with new cue points and information.

This works OK here:

Here is how the code should read without comments:

var
i: integer;

begin
for i := 0 to CurrentPlaylist.GetCount - 1 do

// If EndType is empty, then do it
if CurrentPlaylist.GetItem(i).GetEndType = ‘’ then

begin

CurrentPlaylist.GetItem(i).SetColored(true);

CurrentPlaylist.GetItem(i).SetColor($80FF80);

CurrentPlaylist.GetItem(i).SaveMMD;

end;
end.

I’m running the latest build 2.1.44 Build 490

Hth Tony

If not we will have to wait for one of the programmers.Ah! Charlie posted at the same time. Hi Charlie.

All I can suggest for research is:

  1. the mAirListScript.chm file (which is fairly easy to understand if you are a programmer), which eplains the mairlist-specific stuff, and

  2. delphibasics.co.uk, which explains how Delphi works, but you need to know that lots od ‘standard’ Delphi simply don’t exist in mairlist script. This isn’t Torben’s fault nor can he do anything about it. It’s because the guy who wrote the scriptiong component did not include ALL of Delphi.

A lot of intelligent trial and error is needed. You will find that there is no InputBox or equivalent. There is no MsgBox or equivalent; which is why the only way to display any message to the user is with SystemLog. Lots of the time and date functions aren’t there, so you need to be devious if you need to do date/time conversions and arithmetic.

I hope that helps?

BFN
CAD