Skip to content

Creating infinite loop #202

Answered by sbooth
angstsmurf asked this question in Q&A
Sep 7, 2021 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

There is no way to schedule a truly infinite repeat but you can get close using SFBLoopableRegionDecoder. It wraps an underlying decoder (which must be seekable) and has various convenience constructors for setting up the region based on starting frame position, frame length, and repeat count. The simplest case for looping an entire decoder is something like:

let decoder = try AudioDecoder(url: url)
let loopedDecoder = try LoopableRegionDecoder(decoder: decoder, framePosition: 0, frameLength: decoder.length, repeatCount: Int.max)
// Use `loopedDecoder`

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@angstsmurf
Comment options

Answer selected by angstsmurf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants