I spent some time playing with AudioSource.time & AudioSource.timeSamples and read some posts about them. So I get that due to audio compression I can't rely on .time for accuracy so I need to use .timeSamples. Yet, when I printed some output of how .timeSamples work coudn't understand the idea behind it at all. I simply made a 30 sec audio loop and with first play it starts from 7526 and 2nd time 38 and every next time it loops, starts and ends with different timeSample values. Why?

What I simply want to achieve is the thing I wrote in the header and also to be able to play the sound at for example the 5th or 10th or any second without losing the accuracy from the compression for android or ios. How can I do that?


1 Answer 1


Pausing and resuming playback can be achieved with this approach:

AudioSource audio = GetComponent<AudioSource>();
float playbackProgress = 0f;


playbackProgress = audio.timeSamples;

audio.timeSamples = playbackProgress 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .