4

I have implemented seeking as discussed here ( AVAssetReader Seeking), however there is of course a noticeable delay while the AVAssetReader is torn down and a new one constructed (since you cannot change the timeRange property once you have begun reading data).

I can imagine that seeking forward in time could be done rather cleanly by just reading the data and skipping it, but seeking backwards in time would always be constrained by this problem...

Any ideas how I can optimize this so the user enjoys scrubbing through an audio track?

Community
  • 1
  • 1
yano
  • 4,095
  • 3
  • 35
  • 68

1 Answers1

0

what you experience here is maybe not lag, but some kind of clicks happening every time you create a new instance of AVAssetReader and read the first samples.

In fact AVAssetReader fades the first 1024 samples (maybe a little more) in.

I fixed it by reading 1024 samples before the position I really want to read, then skip that 1024 samples.

I hope it'll work for you also.

Cyril
  • 206
  • 1
  • 5
  • I don't think I am observing this behavior. The delay I'm talking about is actual CPU time required to instantiate an AVAssetReader instance. – yano Jan 17 '13 at 00:37