This PAL script starts by ensuring there is at least 1 track in the queue and if not, it adds a track from the Music (All) category but you can change this to whatever category you use to store your required tracks.
The first time it runs, if the queue was empty then the queue will have one track added and then the second part of the script will add random tracks from the same category until there are 3 tracks in the queue. When the queue contains only 1 track, additional tracks are added to ensure there are 3 tracks. You can adjust this limit if you want.
// PAL Script to Add Random Tracks
// from a Specified Directory to the Queue
// Loop the Script
PAL.loop := True;
// Check for an empty queue and add 1 track if empty
If Queue.Count < 1 then
Cat['Music (All)'].QueueBottom(smRandom, NoRules);
//Wait until there is only 1 track in the Queue
PAL.WaitForQueue(1);
// When there is only 1 track in the Queue, keep 3 random tracks queued
// from a specified directory
while Queue.Count < 3 do
Cat['Music (All)'].QueueBottom(smRandom, NoRules);
This is a very basic script designed to add tracks to the queue from a specified directory or category. If we remove the comments from this script, we only have six lines of code:
PAL.loop := True;
If Queue.Count < 1 then
Cat['Music (All)'].QueueBottom(smRandom, NoRules);
PAL.WaitForQueue(1);
while Queue.Count < 3 do
Cat['Music (All)'].QueueBottom(smRandom, NoRules);
First we need to ensure the script will continue to run.
Second we check for the number of tracks in the queue and if the queue is empty, a single track is added to the queue.
Third we wait for the number of tracks in the queue to equal 1 and then we add enough tracks so there are three tracks in the queue.
There are simpler ways to achieve the same result but this short example script shows three different ways to utilize the number of tracks in the queue.
The number of tracks can be adjusted as necessary.
Comments