Update playlist player

Hello,
I’m working on a project that is basically an adaptation of threads found in this forum for a multipurpose player.

The player is opening a directory and grabbing different file types (video, image, pdf) and play’s them on a loop. The loop is made from each video file duration + 10 seconds for the images file and 20 seconds for the pdf file.

Now I want to be able to upload a file to that directory and without reinitialising the player to be able to update the array and to extend the loop with that file.

Please if anybody can provide a simple example for the update function or how can I add another value randomly in my loop and display it in the draw while the player is running so that at the next loop the value is loaded.

As far I have read this forum and based on my lack of experience both with of and c++ my next approach to the problem will be to initialise the player in a window, update the playlist in the background, start another window, and at the beginning of the next loop close the initial window.

Thank you for your time.

I have made a simple example to my little problem:

In the h file:

vector  <ofVec2f>   files;
vector  <int>       seconds;

int counter_files;
int loop_nr;

float   time;
float   wait;
bool    marker;

/// FOR ADDING ANOTHER FILE AT A RANDOM POINT IN TIME

float   time2;
float   wait2;
bool    marker2;

setup():

int counter = 1;

/// Add seconds to files for the playlist (static version);
// [small values more time to spare]

seconds.push_back(2);    /// Video file 
seconds.push_back(2);    /// Image
seconds.push_back(2);    /// Image
seconds.push_back(3);    /// PDF

    for (int i = 0; i < seconds.size(); i++){
        files.push_back(ofVec2f());
        files.back().set(counter, seconds[i]);
        counter++;
    }

 cout << "FILES IN VECTOR" << "\n" << endl;

    for (int i = 0; i < files.size(); i++){
        cout << " Playlist order: " << files[i].x << " > Seconds to play: " << files[i].y << endl;
    }

 cout << "\n" << "* START *" << "\n" << endl;

/// PLAYLIST
marker = false;
time = (int)ofGetElapsedTimeMillis()/1000;
loop_nr = 1;

/// ADD ANOTHER FILE TO THE PLAYLIST
marker2 = false;
time2 = (int)ofGetElapsedTimeMillis()/1000;

/// RANDOM TIME

wait2 = (int)ofRandom(10, 30);
cout << " @ Add another file in: " << wait2 << " seconds\n" << endl;

draw()

int clock = (int)ofGetElapsedTimeMillis()/1000 - time;
int clock2 = (int)ofGetElapsedTimeMillis()/1000 - time2;

    if (clock == wait && !marker){
        cout << "Play file " <<"(" << files[counter_files].x << ") " << "for: > " << files[counter_files].y << " < seconds \n" << endl;
        marker = false;
        time    = (int)ofGetElapsedTimeMillis()/1000;
        counter_files++;

            if (counter_files == files.size()){
                counter_files = 0;

                cout << "\n<<< LOOP: " << loop_nr << "\n\n" << endl;
                loop_nr++;
            }

        wait = files[counter_files].y;
    }

 if (clock2 == wait2 && !marker2){
    marker2 = true;

    cout << "\n ### Another file has been added ### \n\n" << endl;

    /// HOW CAN I ADD ANOTHER FILE TO THE LOOP ????

 }