playerstate script problem

Hi freaks,

I want to use this script in mairlist but i get this error:

26-5-2017 16:26:50 Fout Runtime error “List index out of bounds (5193937)” in background script C:\Users\Broadcast pc\Desktop\kort script.mls, handling message: PLAYERCONTROL_STATECHANGE 700AA6C620701FE5 00 00000000 00000000 08 00 ?

Sombody who know what i do wrong?

// Called when (playlist) player changes its state
procedure OnPlayerStateChange(PlaylistIndex: integer; PlayerIndex: integer; OldState:

TPlayerState; NewState: TPlayerState);
begin
if (PlayerIndex = 0) and (NewState = psLoaded) then begin // Player 1 is now “loaded”
IOWarriorRemote(0).SetPort(24, true);
IOWarriorRemote(0).SetPort(25, false);
IOWarriorRemote(0).SetPort(26, false);
end;
if (PlayerIndex = 0) and (NewState = psPlaying) then begin // Player 1 is now “playing”
IOWarriorRemote(0).SetPort(24, false);
IOWarriorRemote(0).SetPort(25, false);
IOWarriorRemote(0).SetPort(26, true);
end;
if (PlayerIndex = 0) and (NewState = psStopped) then begin // Player 1 is now “stopped”
IOWarriorRemote(0).SetPort(24, false);
IOWarriorRemote(0).SetPort(25, false);
IOWarriorRemote(0).SetPort(26, false);
end;
// etc.
end;

begin
end.

Thanks in advance

Please check the latest Background Script Template file in the program folder; various procedures, including OnPlayerStateChange, have received an additional parameter. You must update the parameter list accordingly.

Hi Torben,

If i only use this script it says the same fault:

// Called when (playlist) player changes its state
procedure OnPlayerStateChange(PlaylistIndex: integer; PlayerIndex: integer; OldState: TPlayerState; NewState: TPlayerState);
begin
if (PlayerIndex = 0) and (NewState = psPlaying) then // Player 1 is now “playing”
IOWarriorRemote(0).SetPort(24, true);
if (PlayerIndex = 0) and (NewState = psStopped) then // Player 1 is now “stopped”
IOWarriorRemote(0).SetPort(25, true);
// etc.
end;

begin
end.

Dirk

The problem is the additional parameter for the procedure.

procedure OnPlayerStateChange(PlaylistIndex: integer; PlayerIndex: integer; OldState: TPlayerState; NewState: TPlayerState);

If you take a look in the Background Script Template file, as Torben said, you can see, that the new command looks like that.

procedure OnPlayerStateChange(PlaylistIndex: integer; PlayerIndex: integer; OldState: TPlayerState; NewState: TPlayerState; Item: IPlaylistItem);

So there is a new parameter called “Item”…

Hi,

Thanks for your replay!

I do understand what you mean, the script is now working whit the new parameters.

Iam happy with it :wink:

Thanks!

Thank Torben, not me! He solves the problem.

Indeed Thanks Torben!

I made this script and it works but after 2 time’s switching on channel 0 the state of 1 channel goes out,

What could be the problem :-[

const
PORT_COUNT = 32;

var
Portflashing: array[0…PORT_COUNT-1] of boolean;
FlashCounter: integer;

procedure OnTimer;
var
i: integer;
begin
FlashCounter:= FlashCounter+1;
if FlashCounter = 2 then FlashCounter := 0;

for i := 0 to PORT_COUNT -1 do
if PortFlashing[i] then
IOWarriorRemote(0).SetPort(i, FlashCounter = 1);
end;

procedure OnLoad;
var
i: integer;
begin
for i:= 0 to PORT_COUNT -1 do
Portflashing[i] := false;
EnableTimer(500);
end;

// Called when (playlist) player changes its state
procedure OnPlayerStateChange(PlaylistIndex: integer; PlayerIndex: integer; OldState: TPlayerState; NewState: TPlayerState; Item: IPlaylistItem);

begin
end;
procedure OnPlayerStart(PlaylistIndex: integer; PlayerIndex: integer; Item: IPlaylistItem);
begin
if (PlaylistIndex= 0) and (PlayerIndex= 0) then begin
PortFlashing[24] := false;
IOWarriorRemote(0).SetPort(24, true);
IOWarriorRemote(0).SetPort(25, false);
end;
if (PlaylistIndex= 0) and (PlayerIndex= 1) then begin
PortFlashing[26] := false;
IOWarriorRemote(0).SetPort(26, true);
IOWarriorRemote(0).SetPort(27, false);
end;
end;

procedure OnPlayerEOFWarning(PlaylistIndex: integer; PlayerIndex: integer);
var
i : integer;
begin
if (PlaylistIndex= 0) and (PlayerIndex= 0) then begin
PortFlashing[24] := true;
end;
if (PlaylistIndex= 0) and (PlayerIndex= 1) then begin
PortFlashing[26] := true;
end;
end;

procedure OnPlayerStop(PlaylistIndex: integer; PlayerIndex: integer; Duration: TTimeValue; Item: IPlaylistItem);

begin
if (PlaylistIndex= 0) and (PlayerIndex= 0) then begin
PortFlashing[24] := false;
IOWarriorRemote(0).SetPort(24, false);
IOWarriorRemote(0).SetPort(25, true);
end;
if (PlaylistIndex= 0) and (PlayerIndex= 1) then begin
PortFlashing[26] := false;
IOWarriorRemote(0).SetPort(26, false);
IOWarriorRemote(0).SetPort(27, true);
end;
end;

begin
end.

Thanks in advance
Dirk

Seems you have missed Item: IPlaylistItem in the middle section 8)

Edit:
Never mind, I looked at the reference template, it looks fine.

No problem!, it works fine now.

I restart mairlist en the error was gone 8)