How to set the start and the end of an audio?

Hi, everyone

I’m just want to know if there is a possible way to set the start and the end of an audio,

for example i have an audio that ends at 30 sec. So how i can make it starts from 2 secs and ends at lets say 25 sec.

Thank you all for your time.

What i did was the following (C#):

I have two floats: startTimesample and endTimesample. In your case startTimesample will be 2 * 44100 (if that’s the frequency that your audio is in) and endTimesample is 25 * 44100.

Now on your Update method:

if (audiosource.timesample < startTimesample) {
    audiosource.timesample = startTimesample;
} else if(audiosource.timesample > endTimesample){
    audiosource.Stop();
}