This script will play the preselected number of adverts through the normal decks after a set number of tracks. The volume is also increased when the adverts play and is reduced when the adverts have finished. There is another script which plays X number of adverts after Y number of tracks through the Aux1 player here.
The number of tracks, adverts and both the normal and loud volume levels can be adjusted in this code segment:
// Declare Adjustable Variables
var NormalVol : integer = 255; // Set the normal volume level here
var LoudVol : integer = 350; // Set the high volume level here
var AdTotal : integer = 5; // Set the number of adverts to play
var PlayCount : integer = 6; // Set the number of tracks to play before queuing adverts
In this configuration, the script will play 5 adverts after 6 tracks are played. The normal volume level is set to 255 which is the default setting and the loud volume level is set to 350 which is maximum volume.
{*****************************************
PAL Script to play Adverts between Tracks
*****************************************}
PAL.Loop := True; // Loop the PAL Script
// Declare TPlayer Variables
var Player1 : TPlayer; // Declare an instance of TPlayer for the Active Player
var Player2 : TPlayer = DeckB; // Declare an instance of TPlayer for the Idle Player
// Declare Variable to Store the Playlist Rules
var MinAlTime : integer;
var MinArTime : integer;
var MinTiTime : integer;
var MinTrTime : integer;
// Declare the TSongInfo Containers
var P1Track, P2Track, P3Track : TSongInfo;
// Variable Declarations
var AdCount : integer; // Used to Count the number of adverts added and played
// Declare Adjustable Variables
var NormalVol : integer = 255; // Set the normal volume level here
var LoudVol : integer = 350; // Set the high volume level here
var AdTotal : integer = 5; // Set the number of adverts to play
var PlayCount : integer = 6; // Set the number of tracks to play before queuing adverts
PAL.WaitForPlayCount(PlayCount); // Set the number of tracks to play before playing the adverts
PAL.LockExecution; // Speed up the Script processing
// Record the current Playlist Rules in Case they are not default
MinAlTime := PlaylistRules.MinAlbumTime;
MinArTime := PlaylistRules.MinArtistTime;
MinTiTime := PlaylistRules.MinTitleTime;
MinTrTime := PlaylistRules.MinTrackTime;
// Set the Playlist Rules to 1 to account for multiple repeats of short adverts
PlaylistRules.MinAlbumTime := 1;
PlaylistRules.MinArtistTime := 1;
PlaylistRules.MinTitleTime := 1;
PlaylistRules.MinTrackTime := 1;
// Check for the Active Player
Player1 := ActivePlayer; // Assign the Active Player to Player1
If Player1 = DeckB Then Player2 := DeckA; // Assign the Idle Player to Player 2
Queue.Clear; // Clear the Queue for the adverts
// Add the required number of adverts to the top of the queue
for AdCount := 1 to AdTotal do
begin
CAT['Advertisements (All)'].QueueTop(smLRP,EnforceRules);
end;
// Wait for the current track to end if it is not an advert
P1Track := Player1.GetSongInfo;
if P1Track['songtype'] = 'S' then
PAL.WaitForPlayCount(1);
// Capture the Track Information from the Active Player
P3Track := ActivePlayer.GetSongInfo;
// Check for an advert and raise the volume
if P3Track['songtype'] = 'A' then
Begin
Player2.Volume := LoudVol; // Increase the Player Volume for the Adverts
Player1.Volume := LoudVol; // Increase the Player Volume for the Adverts
AdCount := 0; // Reset AdCount to 0
end;
// Count the Adverts before reducing the Player Volume
while (AdCount < AdTotal) AND (P3Track['songtype'] <> 'S') do
begin
PAL.WaitForPlayCount(1); // Wait for the Advert to Play
P3Track := ActivePlayer.GetSongInfo; // Capture the next Track Information
end; // end for the While loop
// Restore the Normal Volume Level
Player2.Volume := NormalVol; // Restore the normal Player Volume level
Player1.Volume := NormalVol; // Restore the normal Player Volume level
// Restore the original Playlist Rules
PlaylistRules.MinAlbumTime := MinAlTime;
PlaylistRules.MinArtistTime := MinArTime;
PlaylistRules.MinTitleTime := MinTiTime;
PlaylistRules.MinTrackTime := MinTrTime;
PAL.UnLockExecution; // Return PAL Script processing to normal speed
// Housekeeping
Player1.Free;
Player2.Free;
P1Track.Free;
P2Track.Free;
P3Track.Free;
Comments