Sound 'full play'.. ?!

 
Greetings,

I built a part in my sound() routine that will force 'full play' of the file it plays (some of them are more the 5 sec).
It does it by extracting the length part that I added to the filename as [6] meaning - 6 sec full play (example:  'time to TP.wav' -> time to TP[6].wav )


Well, in most cases it works, but when there is a price movement, the EA starts its sequence from the beginning
and if there is another sound to play, it cuts the present one.

Is there a way to prevent it from happening?

Thank you,

James

 

         play_time=TimeCurrent();
         PlaySound(file_to_play);
         for( i = ArraySize(sound_stack)-1; i > 0; i --) //storing the last new played event
            {
             sound_stack[i]=sound_stack[i-1];
             time_stack[i]=time_stack[i-1];
             sound_stack[0]=file_to_play;
             time_stack[0]=play_time;
            }

         while (TimeCurrent()-play_time<length)
               {
                first=StringFind(file_to_play,"[",0)+1;
                second=StringFind(file_to_play,"]",first);
                length=second-first;
                if (length<1) length=1; // this var is used to extract the true length
                length=StrToInteger(StringSubstr(file_to_play,first,length));
                if (length<1) length=1;  // this var is the true length (sec) of 'file_to_play' wav file
               }  // a way to force a pause letting a full play
         Print ("Exiting the pause loop after ",TimeCurrent()-play_time," sec.  Playd: ",file_to_play);

 

Reason: