Airence player script

Was half way :grinning: already changed CurrentPlaylist for Playlist(0)
That didn’t give the wanted result .
Try tomorrow PlaybackControl(0)

Thanks again

With PlaybackControl(0) and Playlist(0 ) it stays the same .
Player A is red when playing one off the carts.

Any (!) other scripts running?

No I have only added like above in what I had but then for for button 19 20 21
procedure OnPlayerStart(PlaylistIndex: integer; PlayerIndex: integer; Item: IPlaylistItem);
begin
if (PlaylistIndex= 1) and (PlayerIndex= 0) then begin
AirenceRemote(0).SetLED(19, acRed);

And that also for 20 and 21

To deal with cart players make use of procedures OnCartwallPlayerStart and -Stop or OnCartwallPlayerStateChange resp., the syntax of which to be found in the file Background Script Template.mls.

What I don’t quite get is the use of a playlist for the cartwall. Is this just to provide some kind of „storing shelf“ or is there some other functionality I don’t see as yet?

There just normal players like player A/B but there used as cart.
The playlist can be used for evrything , jingles records .
It’s used a lot in the Netherlands Dalet started and now we have Omniplayer in the national radio stations mostly the have 4 carts like this .

Okay, then forget about what I said about Cartwalls, leave the first script (for Playlist(0)) as is and incorporate a second script like this:


procedure CheckPlayer;
var
  i: integer;
begin
  for i := 0 to 2 do
  begin
    if Playlist(1).GetPlayer(i).GetIsNext then
      AirenceRemote(0).SetLED(19 + i, acGreen)
    else
    begin
      case PlaybackControl(1).GetPlayer(i).GetState of
        psLoaded: 
          AirenceRemote(0).SetLED(19 + i, acYellow);
        psPlaying:
          AirenceRemote(0).SetLED(19 + i, acRed);
        psEmpty: 
          AirenceRemote(0).SetLED(19 + i, acNone);
        psPaused:  
          AirenceRemote(0).SetLEDBlink(19 + PlayerIndex, acRed, acYellow, absFast);
      end;
    end;
  end;
end;

procedure OnLoad;
var
  i: integer;
begin
  for i := 0 to 2 do
    AirenceRemote(0).SetLED(19 + i, acNone);
  CheckPlayer;
end;

procedure OnUnLoad;
var
  i: integer;
begin
  for i := 0 to 2 do
    AirenceRemote(0).SetLED(19 + i, acNone);
end;

procedure OnPlayerStateChange(PlaylistIndex: integer; PlayerIndex: integer; 
  OldState: TPlayerState; NewState: TPlayerState; Item: IPlaylistItem);
begin
  if PlaylistIndex = 1 then
    CheckPlayer;
end;

begin
end.

 
Hope this works.

At home and imported you script in a new script and get a error : [Error] (19:45): Unknown identifier ‘PlayerIndex’

Try it also with a script that only addresses the cartplayers , works great but when you ad your first script it shows the player A (17) button again :thinking:

Let me explain it one more time Player 1 till 3 19 20 and 21 have all 1 playlist so 19 has playlist 1 ,20 has playlist 2 and 21 has playlist 3 there is no next state because there is only 1 player with 1 playlist.

Copy-and-paste-Error: change

psPaused:  
  AirenceRemote(0).SetLEDBlink(19 + PlayerIndex, acRed, acYellow, absFast);

to

psPaused:  
  AirenceRemote(0).SetLEDBlink(19 + i, acRed, acYellow, absFast);

please.

 

Okay, have to think about that.

Works on button 19 with a new error 7-3-2022 16:29:15 Error Runtime error “Range check error” in background script handling message: PLAYERCONTROL_STATECHANGE 4CEBA09C6C531710 00 00000001 00000000 05 00 ?

And still button 17 lights up when starting player 1 (19)

It feels like I take a lot off your time , its no obligation :sweat_smile:
But its appreciated a lot

Okay, what about this (as the second script):

procedure OnLoad;
var
  i: integer;
begin
  for i := 0 to 2 do
    AirenceRemote(0).SetLED(19 + i, acNone);
end;

procedure OnUnLoad;
var
  i: integer;
begin
  for i := 0 to 2 do
    AirenceRemote(0).SetLED(19 + i, acNone);
end;

procedure OnPlayerStateChange(PlaylistIndex: integer; PlayerIndex: integer; 
  OldState: TPlayerState; NewState: TPlayerState; Item: IPlaylistItem);
begin
  if  PlaylistIndex > 0 then
  begin
    case NewState of
      psLoaded: 
        AirenceRemote(0).SetLED(18 + PlaylistIndex, acYellow);
      psPlaying:
        AirenceRemote(0).SetLED(18 + PlaylistIndex, acRed);
      psEmpty: 
        AirenceRemote(0).SetLED(18 + PlaylistIndex acNone);
      psPaused:  
        AirenceRemote(0).SetLEDBlink(18 + PlaylistIndex, acRed, acYellow, absFast);
    end;
  end;
end;

begin
end.

(Untested. Please try.)

Same as my script ( yours with less text :smiley:) everything works but when playing player A lights up.
And I beginning to learn something there was an error , you forgot a , (psEmty)

Disable the first script and run the (new) second only, please.

Then the 3 players run without lighting up player A

In this case the trouble comes from the first one. Please change OnPlayerStateChange in the first script again to

procedure OnPlayerStateChange(PlaylistIndex: integer; PlayerIndex: integer; 
  OldState: TPlayerState; NewState: TPlayerState; Item: IPlaylistItem);
begin
  if PlaylistIndex = 0 then
  begin
    CheckPlayer;
    case NewState of
      psPlaying: AirenceRemote(0).SetLED(17 + PlayerIndex, acRed);
      psPaused:  AirenceRemote(0).SetLEDBlink(17 + PlayerIndex, acRed, acYellow, absFast);
      psEmpty:   AirenceRemote(0).SetLED(17 + PlayerIndex, acNone);  
    end;
  end;
end;

Yes!!! super thanks a lot
There where 2 errors but I found them myself .

Good. Always a little awkward to debug remotely. Would you please be so kind and post the two working scripts so that future Airence owners can make use of them?

1 Like

Script for player’s A - B on button 17 18

function abs(r: integer): integer;
begin
  if r < 0 then
    Result := r * -1
  else
    Result := r;
end;

procedure CheckPlayer;
var
  i, k: integer;
begin
  for i := 0 to 1 do
  begin
    k := abs(i - 1);
    if CurrentPlaylist.GetPlayer(i).GetIsNext then
    begin
      AirenceRemote(0).SetLED(17 + i, acGreen);
      if CurrentPlaybackControl.GetPlayer(k).GetState  <> psPlaying then
        AirenceRemote(0).SetLED(17 + k, acYellow)
      else
        AirenceRemote(0).SetLED(17 + k, acRed);
    end;
  end;
end;

procedure OnLoad;
var
  i: integer;
begin
  for i := 0 to 1 do
    AirenceRemote(0).SetLED(17 + i, acNone);
  CheckPlayer;
end;

procedure OnUnLoad;
var
  i: integer;
begin
  for i := 0 to 1 do
    AirenceRemote(0).SetLED(17 + i, acNone);
end;

procedure OnPlayerStateChange(PlaylistIndex: integer; PlayerIndex: integer; 
  OldState: TPlayerState; NewState: TPlayerState; Item: IPlaylistItem);
begin
  if PlaylistIndex = 0 then
begin
  CheckPlayer;
  if NewState = psPlaying then
    AirenceRemote(0).SetLED(17 + PlayerIndex, acRed)
  else if NewState = psEmpty then
    AirenceRemote(0).SetLED(17 + PlayerIndex, acNone);  
end;
end;


begin
end.

Script for 3 extra player’s (omniplayer look) on button’s 19 20 21

procedure OnLoad;
var
  i: integer;
begin
  for i := 0 to 2 do
    AirenceRemote(0).SetLED(19 + i, acNone);
end;

procedure OnUnLoad;
var
  i: integer;
begin
  for i := 0 to 2 do
    AirenceRemote(0).SetLED(19 + i, acNone);
end;

procedure OnPlayerStateChange(PlaylistIndex: integer; PlayerIndex: integer; 
  OldState: TPlayerState; NewState: TPlayerState; Item: IPlaylistItem);
begin
  if  PlaylistIndex > 0 then
  begin
    case NewState of
      psLoaded: 
        AirenceRemote(0).SetLED(18 + PlaylistIndex, acGreen);
      psPlaying:
        AirenceRemote(0).SetLED(18 + PlaylistIndex, acRed);
      psEmpty: 
        AirenceRemote(0).SetLED(18 + PlaylistIndex, acNone);
      psPaused:  
        AirenceRemote(0).SetLEDBlink(18 + PlaylistIndex, acRed, acYellow, absFast);
    end;
  end;
end;

begin
end.

begin
end.
1 Like